In one of my recent projects, I needed to point to different data sources by run-time environment.
In the web container, we can define jndi data sources. But what about in the batch environment?
I have heard of something like dummy jndi but I have some problem trying to understand it. So I figured out another way.
In the applicationContext.xml file, I used propertyConfigure to define location at classpath:application.${runtime}.properties.
Then I created two properties file, application.development.properties and application.production.properties.
Then in the applicationContext.xml file, I just pick up the properties.
Then in the command line, I just need to specify the "runtime" variable by using -Druntime=development or -Druntime=production.
Done.
Note: if in applicationContext we need a value "\\abc\aaa", we need to define it in the properties file as "\\\\abc\\aaa".
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment