开发者

Creating one big War file out of 2 war projects

开发者 https://www.devze.com 2022-12-24 23:12 出处:网络
Anyone knows a decent way to merge 2 war modules in to one big war file ? Maybe through some custom maven plugin , or m开发者_高级运维aven-war-plugin configuration ?

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

Maybe through some custom maven plugin , or m开发者_高级运维aven-war-plugin configuration ?

Thanks


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.


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.

0

精彩评论

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