Skip to content

Instantly share code, notes, and snippets.

@bernerbrau
Last active December 12, 2015 01:48
Show Gist options
  • Save bernerbrau/4694046 to your computer and use it in GitHub Desktop.
Save bernerbrau/4694046 to your computer and use it in GitHub Desktop.
How I do external configuration using a global command line variable in Java/Spring
<context:annotation-config />
<!-- System Properties -->
<context:property-placeholder
system-properties-mode="OVERRIDE" ignore-unresolvable="true" />
<!-- Externally Configured Properties -->
<util:list id="configLocations">
<value>classpath:defaultConfig.properties</value>
<value>file:${externalConfiguration:}</value>
</util:list>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:ignoreResourceNotFound="true" p:locations-ref="configLocations" />
<bean id="appConfig" class="org.springframework.beans.factory.config.PropertiesFactoryBean"
p:ignoreResourceNotFound="true" p:locations-ref="configLocations" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment