Announcement Announcement Module
Collapse
No announcement yet.
How to dynamically change the Bean properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to dynamically change the Bean properties

    I configure the hsqldb setting on the xml file like the above,

    But, I want my application accepts a command arguement and then change the "url" property to

    jdbc:hsqldb:C:\RAD Workspace\client-spring\<arg_value>\db\clientcache

    therefore, my application can support multiple instances running today if needed. But, how can I do it?


    program
    ======

    appContext = new ClassPathXmlApplicationContext(new String[] {
    "config/fox-client.xml"
    });


    xml file
    ======

    <bean id="clientCacheDS" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>org.hsqldb.jdbcDriver</value>
    </property>
    <property name="url">
    <value>jdbc:hsqldb:C:\RAD Workspace\client-spring\db\clientcache</value>
    </property>
    <property name="username">
    <value>sa</value>
    </property>
    <property name="password">
    <value></value>
    </property>
    </bean>

  • #2
    You might want to take a look at the PropertyPlaceHolderConfigurer. That one operates on property files. That way you can have different property files for different environments.

    Comment


    • #3
      Have you looked at PropertyPlaceholderConfigurer? This can use system proeprties to replace values. So your command line parameter -Dmyurl=blah should work fine.
      http://www.springframework.org/docs/...onfigurer.html

      Comment

      Working...
      X