Quantcast
Channel: User Sefran - Stack Overflow
Viewing all articles
Browse latest Browse all 36

Java web app: Tomcat and configuration files .properties

$
0
0

I have a java web app with Tomcat as servlet container.

I would to use different configuration files for different build configurations, i.e.

1) demo.properties

2) real.properties

3) test.properties

in which I would to specify the database name, db user and password (now for the db I use JNDI resource configuration in app context.xml), if send mail should be enabled or not (now I have two methods whose content I have to comment or not according to the purpose), some css image paths and some other stuff.

If it's possible to do so, how can I extrapolate db connection from context.xml? and How can I prevent to send email if my app is test or demo?

EDIT 2

Thanks to Anton Shchastnyi's answer to this question, I succeeded in extrapolating db connection parameters from context.xml (say in configApp.properties).

The configApp.properties must be in Tomcat lib folder together with .class which implements IntrospectionUtils.PropertySource.

So, how could I generalize this solution such that it can be used for different web app deployment? (I prepare the .war locally, then it's deployed on remote server)


Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>