你实际上是在定义你的 tomcat7-maven-plugin 只有在 pluginManagement 但不要把它转介到外面的任何地方 build.plugins 部分。
tomcat7-maven-plugin
pluginManagement
build.plugins
你的版本略有改动 pom.xml 仅显示相关部分可能是:
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>userpom</artifactId> <groupId>com.test</groupId> <version>1.0-SNAPSHOT</version> </parent> […] <build> <finalName>userweb</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <!--<plugin>--> <!--<artifactId>maven-deploy-plugin</artifactId>--> <!--<version>2.8.2</version>--> <!--</plugin>--> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>TomcatServer</server> <path>/usertest</path> <update>true</update> </configuration> <executions> <execution> <id>tomcat-deploy</id> <phase>install</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
如果继承父pom.xml的所有工件都将受益于您的预配置 tomcat7-maven-plugin 然后拉 pluginManagement 从你的分段出来 pom.xml 并把它放入 build 你父母的一部分 pom.xml 。
build