First, some context:
I\'m currently working on a project in which I use the Spring framework on Google\'s AppEngine (GAE) to fetch some data from one of Google\'s se
A couple of options:
You can use a prefix to control environment specific properties, this can be done by using system variables:
<util:properties id="googleProperties"
location="WEB-INF/${ENV_SYSTEM:dev}/google.properties" />
In this case it will always look under:
<util:properties id="googleProperties"
location="WEB-INF/dev/google.properties" />
by default, unless a ENV_SYSTEM
system variable is set. If it is set to qa
, for example, it will automatically look under:
<util:properties id="googleProperties"
location="WEB-INF/qa/google.properties" />
Another approach is to make beans profile specific. For example:
<beans profile="dev">
<util:properties id="googleProperties"
location="WEB-INF/google-dev.properties" />
</beans>
<beans profile="qa">
<util:properties id="googleProperties"
location="WEB-INF/google-qa.properties" />
</beans>
The appropriate googleProperties
will loaded depending on a profile set. For example this will load WEB-INF/google-dev.properties
:
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.getEnvironment().setActiveProfiles( "dev" );
ctx.load( "classpath:/org/boom/bang/config/xml/*-config.xml" );
ctx.refresh();
You are on the right track, in our application we have the same scenario and we use "profiles" to manage the properties. We use two configuration files one for Production and another one for testing with profiles set accordingly.