I am doing some refactoring on a Spring MVC application, pulling out configuration data and login crentials from the spring.xml file.
What I want to do is to consolodate sensitive data into external .properties files that can be read, at runtime by the app and not require recompiling the war to make changes.
Thanks to Ben Northrop and Summa Technologies for such a clear, concise and well written article.
The long and the short of it (copied from the aforementioned article) is to add the following to your spring.xml
<bean id=”propertyPlaceholderConfigurer”
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
<property name=”locations”>
<list>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
<bean id=”dataSource” class=”com.mchange.v2.c3p0.ComboPooledDataSource”>
<property name=”user” value=”${db.user}”/>
<property name=”password” value=”${db.password}”/>
…
</bean>