Java application: Tomcat and .properties configuration files

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)

+1
java tomcat7 struts-1 config properties-file
Oct 27 '14 at 1:47
source share

No one has answered this question yet.

See similar questions:

fifteen
External configuration of Tomcat
0
Various layout configurations in the Eclipse and .properties file.

or similar:

1571
How to avoid Java code in JSP files?
1376
How to create java string from file contents?
1315
How to create a file and write it in Java?
39
How to provide context configuration for a web application in Tomcat?
5
A web application deployed to a remote Tomcat instance using IntelliJ cannot find the JNDI resource (javax.naming.NameNotFoundException)
2
Why does HikariCP create a new connection for every web application in Tomcat at startup
0
Configure Tomcat 8 and Shiro with JNDI
0
Configure hibernate 4 to connect to the database via JNDI Datasource in tomcat 7
0
context root configuration in WAR file in Tomcat 7
0
Oracle 10g JNDI Datasource configured on my Tomcat 7 server not working



All Articles