问题
I am trying to use module as a dependency in another project by deploying it to our nexus repository. The problem is that maven tries to deploy the jar twice and our policy forbids to overwrite a release version. The module is packaged as a war. Here is my configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>build-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
<configuration>
<attachClasses>true</attachClasses>
<failOnMissingWebXml>true</failOnMissingWebXml>
</configuration>
</plugin>
When I set attachClasses to false, everything goes fine and the war gets deployed, but the jar doesn't. When I set it to true, the jar gets deployed but maven tries to deploy a second time and then the build fails. Any idea why maven tries to deploy it twice. (The module has a parent module, but it does not depend on any other module from the project).
回答1:
The problem is probably that you defined your own execution.
Try to remove the block
<executions>
<execution>
<id>build-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
来源:https://stackoverflow.com/questions/59376513/maven-jar-deployed-twice-in-a-war-module-with-attachclasses-set-to-true