Announcement Announcement Module
Collapse
No announcement yet.
Problem getting System Environment variable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem getting System Environment variable

    Hi

    I want load different database properties for different environment based on a System Environment Property 'ENV'. I was trying it by putting ${ENV}
    as shown below :

    :- part from my applicationContext.xml
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">
    <value>classpath:db.properties.$ENV</value>
    </property>
    </bean>



    <bean id="hibDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"><value>${driverClassName}</value></property>
    <property name="url">
    <value>${url}</value>
    </property>
    <property name="username"><value>${username}</value></property>
    <property name="password"><value>${password}</value></property>
    </bean>

    But I am getting exception since the SystemPropertyUtil class used by Spring framework to resolve place holders uses System.getEnv() which is deprecated and thus I get an exception : "getenv no longer supported, use properties and -D instead: " + ENV

    Is there any other way I can get this property value ?

    Also I tried setting Tomcat Environment variable for my application so that I can pick up the value of 'ENV' from there but not able to get it . Any suggestion How can I get Environment varaible set in Tomcat in my applicationContext.xml

    A quick help would be highly appreciated.

    Thanks in advance to all.

  • #2
    What JDK are you using? It was deprecated in 1.4 but I think it's ok in 1.5.
    http://java.sun.com/j2se/1.5.0/docs/...a.lang.String)
    Last edited by karldmoore; Aug 29th, 2007, 10:52 AM.

    Comment


    • #3
      Hi karldmoore

      Thanks for the reply, I want to get workaround in jdk1.4.2 as i need to code for jdk 1.4.2.

      Comment

      Working...
      X