Results 1 to 2 of 2

Thread: PropertyPlaceholderConfigurer: environment variable for file location

  1. #1
    Join Date
    Sep 2009
    Posts
    27

    Default PropertyPlaceholderConfigurer: environment variable for file location

    Hello,

    I'm looking at the PropertyPlaceholderConfigurer.

    http://static.springsource.org/sprin...lderconfigurer

    Is it possible do define the location of a properties file using an environment variable?

    So, one would:

    Code:
    set MY_APP_CFG=/path/to/custom.properties
    and then the application context would pick them up with something like:

    Code:
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>envPath:MY_APP_CFG</value>
        </property>
    </bean>

  2. #2
    Join Date
    Nov 2007
    Posts
    420

    Default

    you can do it this way
    Code:
            <bean 
    		id="placeholderConfigConfig" 
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    		p:ignoreUnresolvablePlaceholders="true">
    		p:systemPropertiesModeName="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
    	</bean>
    
    	<bean 
    		id="propertyConfigurer" 
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    		p:ignoreUnresolvablePlaceholders="true"
    		p:location="${name_of_your_env_property}">    		
    	</bean>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •