打算使用maven的tomcat插件来自动部署项目,但是遇到了问题,先记下解决问题过程以避免犯错。
情况描述:
- 找到官方的配置模块地址:https://tomcat.apache.org/maven-plugin-2.2/
- 错误示范:直接到project标签下开始配置,如图:
<project>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--Deploy to server-->
<url>http://localhost:8080/manager/text</url>
<server>tomcat7</server>
<username>admin</username>
<password>admin</password>
<path>/${build.finalName}</path>
<port>8080</port>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</project>
3、找解决办法:
第一种:您必须使用build标签包围plugins标签,如下所示:
<build>
<plugins>
<plugin>
...
</plugin>
</plugins>
</build>
第二种:或者使用build和pluginManagement标签
<build>
<pluginManagement>
<plugins>
<plugin>
...
</plugin>
</plugins>
</pluginManagement>
</build>