开发者

How to use in Tomcat a datasource without having to edit context.xml?

开发者 https://www.devze.com 2023-03-11 16:20 出处:网络
I have to deploy my web app to a shared server where I can\'t edit the context.xml file to set a new resource factory. Is there a way I could place ALL my hibernate datasource configurations in a file

I have to deploy my web app to a shared server where I can't edit the context.xml file to set a new resource factory. Is there a way I could place ALL my hibernate datasource configurations in a file outside my .war, but still inside the deployment folder (the one I have access to).

My ultimate goal is to develop a "portable" web app, so I can easily migrate from one server to another, just edi开发者_开发问答ting manually my database configurations in a datasource file. Does anyone knows a functional way to do it?

Ps. I imagine Spring would help with this matter. But I don't feel like to set up it for a simple web app or just for this purpose.


According to http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#context.xml_configuration you can have a per-application context file as well, however that must of course be deployed inside your war file. Your best bet might be to modify your build file so that it uses the correct context.xml when creating the war.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号