Creating one big War file out of 2 war projects

痞子三分冷 提交于 2019-12-24 00:19:03

问题


Anyone knows a decent way to merge 2 war modules in to one big war file ?

Maybe through some custom maven plugin , or maven-war-plugin configuration ?

Thanks


回答1:


The maven Cargo plugin can merge WAR files but I've never used this outside a testing context (where I had full control on what I wanted to merge).

For simpler scenarios, you can maybe use overlays.

But none of these solutions will magically solve collisions. You'll have to do some choices.




回答2:


It's not that simple.

The basic problem is that each WAR is its own namespace within the container, so simply mashing them together could readily produce conflicts if WAR A overwrites something in WAR B (index.jsp is a good example).

The prudent thing is to take each WAR and put them in to their own subtree of a new WAR, but even still you have "global" artifacts that would need to be resolved, notably the contents of the web.xml, but also things like properties files that tend to be "one per WAR", log4j.properties for example.

Finally, a portable WAR doesn't "hard code" it's WARs name in to their links, but rather relies on getting the context path from the request. However, if you merge two WARs underneath a master WAR, the context path is only to the root of the application, not the specific sub directory of each individual WAR. So, you'll need to hunt down all of those references, or references where the path was hard coded, and correct them.

So, there's really no automated way to merge WARs.



来源:https://stackoverflow.com/questions/2524058/creating-one-big-war-file-out-of-2-war-projects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!