Results 1 to 3 of 3

Thread: Properties file assistance

  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Default 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 at 11:20 AM. Reason: Extra Info

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2011
    Posts
    2

    Default

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

Tags for this Thread

Posting Permissions

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