I'm having some trouble using @PropertySource, I get an NPE when using 'env.getProperty(..).
Does anybody have any insight?
My environment:
JDK/JRE: 1.6.0_06
OS: Linux Mint 13
Spring: 4.1.6.RELEASE
The stacktrace
My properties file:
My config class:
Model class:
Failed attempts (a bit random!!):
#1 I have tried playing around with the @PropertySource annotation, for example using the file: prefix and absolute path to the properties file.
Dropping the backslash before the classpath eg/@PropertySource("classpath:com/mycompany/app/app.properties").
Putting the properties file in different places.
#2 I've also tried using @PropertySources containing an @PropertySource annotation too.
#3 I've added:
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
Any help/advice much appreciated!!