Recently, I was working on a project and used Maven to manage the dependencies between projects. I encountered a problem and was about to toss to death, but I initially tried a solution. The problem and solution are described here for sharing.
Problem description: There are two projects A and B, Dynamic Web Project. The dependency is, B-->A, one way is to use the Overlay mechanism of maven-war-plugin (see the official website for an example), but this solution defaults to merging the resources of two web applications, and the related class All will be copied to WEB-INF/classes, and related JSP and other resources are also merged together. My requirement is that A's class is independently packaged into a jar, and exists under the WEB-INF/lib of B application after it is published to the application server, and other resources of A application are not required.
Processing ideas:
1. POM processing of application A
<?xml version="1.0" encoding="UTF-8"?>
<project ......">
<modelVersion>4.0.0</modelVersion>
<groupId> com.xxx</groupId>
<version>0.0.1-SNAPSHOT</version>
<name>A-web</name>
<artifactId>A-web</artifactId>
<packaging>war</packaging>
<build>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!--Pay attention to adding these two lines, the related classes will be marked independently when packaging jar-->
<attachClasses>true</attachClasses>
<classesClassifier>api</classesClassifier>
</configuration>
<version>2.3</version>
<executions>
</executions>
</plugin>
</plugins>
</build >
</project>
After the package is complete, include A-web.war and a-web-api.jar and other files.
2. POM processing of application B
<?xml version="1.
Maven-supported War application depends on the solution of another WAR application
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=327071244&siteId=291194637
Recommended
Ranking