Externalizing tomcat jdbc connection pool informat

2019-04-12 19:15发布

问题:

Greetings,

I'm looking for a good solution for externalizing the JNDI connection pool information in context.xml of a war so that as the application moves from dev to QA to prod, the war file won't need to be recompiled. Ideally the url, driver, username and password would be variablized and then populated by means of a properties file that would customized for each environment. If this isn't possible, are there other suggestions on how to handle moving a war across environments without recompiling for a target environment? Maven provides profiles this requires a build targeted at a specific environment.

Thanks in advance.

回答1:

Why don't you just configure this at the Tomcat level instead of embedding a context.xml? To me, this makes particularly sense since Dev, QA, Prod can use different pool settings. And by this, I mean the configuration/sizing of the pool, not only not only the url, username and password.



回答2:

You can have a context.xml that lives outside the WAR files in the common "conf" directory. See the docs.