<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:${jdbc.configuration}"/>
</bean>
<!-- Datasource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
and set the "jdbc.configuration" parameter as a VM parameter. When the propertyResolver doesn't find an existing property, it tries to fallback on the VM's system parameters, and this is just what we need.
Only the external configuration file contains the actual jdbc values, while applicationContext.xml doesn't contain any hardcoded data. Very smooth and clean!

No comments:
Post a Comment