env.getProperty not working Spring PropertyPlaceholderConfigurer
java, spring, spring-4
Solution
A `PropertyPlaceholderConfigurer` does not add the properties from its `locations` to the `Environment`. With Java config, you can use `@PropertySource` to do that.
Problem
I am loading properties file using spring ``` <bean id="appProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="classpath:/sample.properties" /> <property name="ignoreUnresolvablePlaceholders" value="true"/> </bean> ``` when i am getting property value using `@Value("${testkey}")` its working fine. but when i am trying to get using env ``` @Resource private Environment environment; environment.getProperty("testkey") // returning null ```