<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath : test.properties"/>
</bean>As we are going to use java.util.Properties we have to define PropertiesFactoryBean as a bean in our context file as below.
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath : test.properties"/>
</bean>
Also we will use @Autowired annotation when retrieving data.So lets define the below in our context file as well.
@Autowired
private Properties properties;
private void test(){
String value=properties.getProperty("key");
}
}
Hope this helps .
No comments:
Post a Comment