Monday, September 28, 2009

Loading a properties file using spring

Example properties file with filename:


On your spring config file, you can load the properties file using the following code

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">

after that, you can now use the values on your properties file by using their key enclosed by a dollar sign and two curly braces. Example code:

<bean id="myUrl" class="">
        <constructor-arg value="${env.protocol}://${}"/>
Spring will now interpret the constructor arg value to be: