Rectangle 27 0

java Spring @Value is not resolving to value from property file?


Problem is due to problem in my applicationContext.xml vs spring-servlet.xml - it was scoping issue between the beans.

Note
Rectangle 27 0

java Spring @Value is not resolving to value from property file?


@Bean 
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

FYI: You don't have to add this Bean with Spring boot 1.5.9 anymore.

I also found the reason @value was not working is, @value requires PropertySourcesPlaceholderConfigurer instead of a PropertyPlaceholderConfigurer. i did the same changes and it worked for me, i am using spring 4.0.3 release. I configured this using below code in my configuration file -

this should be marked as correct response

Note