Is it possible to combine 2 web.xml with a Maven overlay

I have a web application "A" defined in a military project. I created another web application โ€œBโ€ that imports all the content โ€œAโ€ with the overlay.

The web.xml file of application "B" is the same as application "A", with the exception of additional listeners. Therefore web.xml B contains a lot of duplicate content with A.

Question: Can I tell maven-war-plugin about merging web.xml from A and B instead of replacing web.xml of file A with web.xml from B?

+6
source share
1 answer

In your case - additional listeners - there is a simple solution. If your application is Servlet 3.0 or higher, you can register listeners B with the annotation:

@WebListener public class BListener implements ServletContextListener { public void contextInitialized(ServletContextEvent sce) { System.out.println("Started BListener"); } 

If exposure B is more complex than an extra listener, you can consider a web fragment (requires Servlet 3.0)

0
source

Source: https://habr.com/ru/post/988854/


All Articles