I have a java web application with Tomcat as a servlet container.
I would like to use different configuration files for different build configurations, i.e.
1) demo.properties
2) real.properties
3) test.properties
in which I would like to specify the database name, user and password db (now for db I use the JNDI resource configuration in the context.xml application) if sending mail should be enabled or not (now I have two methods whose contents I must comment or not according to purpose), some css image paths and some other things.
If possible, how can I extrapolate a db connection from context.xml ? and how can I prevent sending emails if my application is a test or demo?
EDIT 2
Thanks to Anton Schastny to answer this question , I managed to extrapolate db connection parameters from context.xml (say, in configApp.properties ).
configApp.properties should be located in the Tomcat lib folder along with .class, which implements IntrospectionUtils.PropertySource.
So, how can I generalize this solution so that it can be used for different deployments of web applications? (I prepare .war locally, then it is deployed to a remote server)
java tomcat7 struts-1 config properties-file
Sefran Oct 27 '14 at 1:47 a.m. 2014-10-27 13:47
source share