Is there a way to read text from external properties file in spring without using the @Value
annotation. Ex: application.properties
var.foo="hello"
I can inject it in a spring bean using
@Value("${var.foo}") String value;
as a class variable. Is there a way to include this property without using the @Value
annotation. Something like how JSR bean validation does.
@NotNull(message={custom.notnull})
and you externalize this property value in ValidationMessages.properties file.
Example, if I have a resource(web component) class, and if I have to use Swagger annotations to document them,
@controller
@path("/")
@Api(description = "User Resource API")
public class UserResource {
@Path("/users")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "returns user details", notes = "some notes")
public User getUser() {
return new User(123, "Joe", "Montana");
}
}
and the model,
@ApiModel("user model")
public class User {
@ApiModelProperty(value = "This represents user id")
private String id;
private String firstName;
private String lastName;
...
}
How do you externalize this string/sentences/messages to an external properties file. I think this applies to general Java annotations and spring and not specific to Swagger. The reason I specified Swagger is, if just like hibernate validation Java library has the option of specifying these messages in an external ValidationMessages.properties file and spring knows by default to pick it up (or can be configured).
Does Swagger provide such an option? If it does not, how do I setup one?
Underlying problem is, I don't want to clutter my code/logic with documentation related data(meta data).