maven cargo 插件自动部署web项目到tomcat
1、新建maven项目,archetype 选择 maven-archetype-webapp。
2、在maven项目中添加依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
这样可以防止jsp页面开头报如下错误:
The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
3、在pom.xml中添加cargo插件
<build>
<finalName>maven08</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<home>D:\Program Files\eclipse-jee-neon-R-win32-x86_64\apache-tomcat-8.0.36</home>
</container>
<configuration>
<type>existing</type>
<home>D:\Program Files\eclipse-jee-neon-R-win32-x86_64\apache-tomcat-8.0.36</home>
</configuration>
</configuration>
<executions>
<execution>
<id>cargo-run</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>