-
Feb 8th, 2007, 04:28 AM
#1
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>
-
Feb 8th, 2007, 04:37 AM
#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.
-
Feb 8th, 2007, 04:38 AM
#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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules