Announcement Announcement Module
Collapse
No announcement yet.
Properties file assistance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Properties file assistance

    Hi,

    Hoping someone might be able to assist. I've got a property file as an environment variable called ENV that's external to my application. I'm able to load that property file no problem at all.

    Code:
      	<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	    <property name="ignoreUnresolvablePlaceholders" value="false"/>
    	    <property name="order" value="1"/>
    	    <property name="locations">
          	      <list>
           		 <value>file:${ENV}</value>
          	      </list>
        	     </property>
      	</bean>
    I'd like to reference another seperate properties file whose path is contained in the ENV properties
    e.g.
    Code:
    different.properties=C:\location\different.properties
    However I'm having an issue trying to load this second file successfully - the values within it don't seem to be being picked up. I've tried

    Code:
    <bean id="differentProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	    <property name="locations">      	
                   <list>
           		 <value>file:${different.properties}</value>
          	    </list>
        	</property>
      </bean>
    and (based on http://blog.springsource.com/2011/02...-management/):

    Code:
    <context:property-placeholder location="${different.properties}"/>
    I'm clearly doing something wrong but not sure what - any help would be appreciated.

    Edit

    The following code does not work either - get a (The system cannot find the file specified)

    Code:
     <bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
         <property name="locations">
           <list>
           		 <value>file:${ENV}</value>
           		 <value>file:${different.properties}</value>
           </list>
        </property>
     </bean>
    Last edited by Airomega; Oct 8th, 2012, 12:20 PM. Reason: Extra Info

  • #2
    That is never going to work... The PropertyPlaceholderConfigurer wont replace the value of another PPC as both are executed in the same lifecycle...

    If you are using Spring 3.1 you are probably better of using profiles instead of hacking/messing around with property files like this.

    Comment


    • #3
      Thanks very much for your answer. I can happily move on to try something else now - thanks for the Spring profiles suggestion.

      Comment

      Working...
      X