Announcement Announcement Module
Collapse
No announcement yet.
PropertyPlaceholderConfigurer: environment variable for file location Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment

    Working...
    X