1.配置maven中的tomcat:
1)Maven内置的tomcat,
在pom.xml中增加如下配置:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
2)配置外置的tomcat:
i.在$CATALINA_HOME/conf/tomcat-users.conf中增加:
<user username="admin" password="password" roles="manager"/>
ii.在$M2_HOME/conf/settings.xml中增加:
<server>
<id>tomcat</id>
<username>admin</username>
<password>password</password>
</server>
iii.在在pom.xml中增加如下配置:其中<server>的值就是$M2_HOME/conf/settings.xml中<id>的值。
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<server>tomcat</server>
<url>http://127.0.0.1:8080/manager</url>
<uriEncoding>utf-8</uriEncoding>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
3.启动tomcat:mvn tomcat6:rum
4. 部署项目到tomcat中,
mvn package tomcat6:redeploy