I have the same setup, but I use maven to build the WARs differently. I use a PropertyPlaceholderConfigurer in the context:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:datasource.properties" ignore-unresolvable="true" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driver}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<!--other beans-->
</beans>
then I setup an environments folder:
src
--main
----environments
------dev
--------datasource.properties
------cert
--------datasource.properties
------prod
--------datasource.properties
Then in my Maven pom, I use a build profile to copy anything in the environment folder based on a parameter flag in the maven command:
<profiles>
<profile>
<id>environment</id>
<activation>
<property>
<name>environment</name>
</property>
</activation>
<build>
<resources>
<resource>
<directory>
src/main/environments/${environment}
</directory>
</resource>
</resources>
<!-- other build config and plugins -->
so the following command:
mvn clean -Denvironment=dev install
would copy the dev datasource.properties to the war