1.在pom.xml文件中加入tomcat7-maven-plugin插件
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://192.168.0.122:8080/manager/text</url>
<server>tomcat7</server>
<update>true</update>
</configuration>
</plugin>
2.在maven的settings.xml中配置tomcat7用户
<server>
<id>tomcat7</id>
<username>tomcat</username>
<password>123456</password>
</server>
3.在配置tomcat的tomcat-user.xml文件
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui" username="tomcat"/>
执行命令
mvn clean tomcat7:deploy -Dmaven.test.skip=true
会把打好的war包上传到192.168.0.122
如果执行
mvn clean tomcat:deploy -Dmaven.test.skip=true
会把打好的war包上传到localhost