Reputation: 3358
I have this class:
@Configuration
@PropertySource("file:/opt/server/server.properties")
public class ServerConfiguration {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
// @Value("${path}")
private String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
If un-comment the @Value annotation, it works fine. But I would like for it to do it automatically. It does it in a Spring-Boot application, but this is a plain Spring 5 mvc application.
Can this even be done without having to annotate every property?
Upvotes: 0
Views: 34
Reputation: 1527
True, in SpringBoot you can use @ConfigurationProperties to avoid using @Value for every field. However, as i know @ConfigurationProperties is only available for SpringBoot (it is a spring boot package).
For more detail : Spring Boot @ConfigurationProperties example
Upvotes: 1