Sunday, February 7, 2016

Spring externalize application configuration

To configure your application is different environment using different setup use the following in Spring framework -
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
        <property name="ignoreResourceNotFound" value="true" />
        <property name="searchSystemEnvironment" value="true" />
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
By default it will read the available in your application classpath. Typically it is available at src/main/resources/default.proerties.

Setup environment variable APPLICATION_CONFIG_HOME which points to directory where customer is available. If the file is available then it will override those properties which you have specified in that file.

For local development user need not required to define this as mostly developers will use the

This setup provies an option to override if required in a particular environment e.g. QA, performance, staging, production, etc.

No comments:

Post a Comment