Advanced Configuration of the Spring MVC Framework
Subject:   Why not do it the proper way?
Date:   2006-03-24 13:39:11
From:   mattinger
Seems to me that maintaining multiple files knowing the specific host that you're using is nightmare. For one, developers typically don't know which host their application will be deployed on, much less what the passwords and usernames for db connections will be (no security officer should let developers have this information).

There are two proper ways to do this:

1. Get the db connection through jndi, as someone suggested earlier, and let your web container supply it through you're deployment file (not WEB-INF/web.xml, but your actual context deployment).

2. Get the db connection properties directly through you're deployment file:

<bean id="servletPropertyConfigurer"
<property name="location"
value="classpath:path/to/" />

This declaration try to retrieve property references from the following locatoins (in order):
1. Servlet Context Parameters
a. Deployment Parameters (conf/Catalina/localhost/app.xml for example)
b. App Parameters (WEB-INF/web.xml)

2. path/to/ in your classpath

That gives you a much more flexible approach,
since you can set reasonable defaults for your
properties in the WEB-INF/web.xml, and supply
real values in your deployment descriptor.