At times it is required to load properties not present in the war file. Typical usage can be have a war/jar file bundled and having property file for different environment such as dev, QA and PROD. It easy to put outside the war so that everytime build is not required. Fortunately is pretty simple in Spring 3.
Just mention this in spring config
<bean id="placeholderConfigConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="systemPropertiesModeName"> <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value> </property> <property name="ignoreUnresolvablePlaceholders"> <value>true</value> </property> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="file:${config}" /> </bean>
The value of config can be set a -Dconfig in runtime environment. Like it project is run using maven it can be set as MAVEN_OPTS parameter.
It you want smarter way then
<context:property-placeholder location="file:${config}"/>
This piece of writing will help the internet viewers for
building up new webpage or even a weblog from start to end.