It's not clear what you're looking for, but I have a utility where it loads properties based on the environment it works on (dev, prod)
public class EnvironmentalPlaceHolderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean { private Resource overrideLocation; public void setOverrideLocation(Resource overrideLocation) { this.overrideLocation = overrideLocation; } if(overrideLocation != null){ if( overrideLocation.exists()) super.setLocation(overrideLocation); else{ logger.warn("Unbale to find "+overrideLocation.getFilename() +" using default"); } }else{ logger.warn("Override location not set, using default settings"); } } @Override public void afterPropertiesSet() throws Exception { setProperLocation(); }
Then you need to define a bean as
<bean class="com.commons.config.EnvironmentalPlaceHolderConfigurer"> <property name="overrideLocation" value="classpath:/jms/${ENV_NAME}-jms.properties" /> <property name="location" value="classpath:/jms/jms.properties" /> </bean>
You need to define the environment record on the machine with the key as "ENV_NAME"
Example: ENV_NAME = prod
In the case of a Windows environment variable and in the case of writing unix to .profile.
You need to maintain properties for each environment as follows prod-jms.properties uat-jms.properties
source share