Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Reading System property for PropertyPlaceholderConfigurer

  1. #11

    Default

    You have brought me to the place where I was:
    If you see the very first post of this thread, I have used file: only.
    but if the user wants to change the file path,
    then he has to modify 'catalina.bat' as well as 'applicationContext.xml'
    the entry made in catalina.bat is used to read property values for my application,
    Code:
    set JAVA_OPTS=%JAVA_OPTS% -DMyProperties.fileName=D:\MyProperty.properties
    and the entry made in applicationContext.xml is used by PropertyPlaceholderConfigurer for reading cronExpression
    Code:
    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="location"><value>file:D:/MyProperty.properties</value></property>
    </bean>
    but both of them are reading MyProperty.properties to get the property value.
    I want PropertyPlaceholderConfigurer to read the properties from a file whose path is set in catalina.bat file.

  2. #12
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Wouldn't this work?
    Code:
    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
      <property name="location"><value>file:${MyProperties.fileName}</value></property>
    </bean>

  3. #13

    Smile

    Thanks a lot.
    It worked perfectely as I wanted it...
    Code:
    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
      <property name="location"><value>file:${MyProperties.fileName}</value></property>
    </bean>

  4. #14
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Not a problem, glad we got there finally .

Posting Permissions

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