简体   繁体   中英

Deploy tomcat webapp with different web.xml

Is there a way of deploying a tomcat webapp with different web.xml (different name and context)?.

The problem:

I have a web.xml which i constantly have to modify (comment out and uncomment) stuff as i develop things - and this makes it a little annoying. Want i want to have is lets say two files:

web.xml
web-dev.xml

And I want my tomcat on my local machine to use web-dev.xml. Ofcouse for production release (ie Hosted server Tomcat will be using normal web.xml - web-dev.xml won't even be published). Its just for the development.

Any ideas where i can specify within tomcat to use web-dev.xml instead of web.xml ?

Thanks

Similarly to @HumbertoPinheiro, I think Maven profiles are a way to go.

Alternatively, this seems like a possible solution ( Reference link : Specify a custom web.xml to an embedded tomcat ):

Context webContext = tomcat.addWebapp("/yourContextPath", "/web/app/docroot/");
webContext.getServletContext().setAttribute(Globals.ALT_DD_ATTR, "/path/to/custom/web.xml");

Tested on Tomcat 7.0.42.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM