tomcat-users.xml,至少要添加manager,manager-gui,manager-script,manager-jmx,manager-status,
添加权限
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<!--admin角色没有的要注意添上-->
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="admin" password="admin" roles="admin,manager,tomcat,manager-gui,manager-script,manager-jmx,manager-status"/>
<!--你用哪个用户做管理员,则需要分配相应的角色,我给admin用户分配了admin和manager连个角色-->
</tomcat-users>
新版无需修改maven的settings.xml文件,网上很多误导别人的
mvn cargo:redeploy
<!-- 远程部署 ,tomcat必须启动-->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.servlet.port>80</cargo.servlet.port>
<cargo.servlet.port>80</cargo.servlet.port>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
<cargo.remote.manager.url>http://localhost/manager</cargo.remote.manager.url>
</properties>
</configuration>
</configuration>
</plugin>
注意:cargo.hostname是必须配置的,如果不配置默认是localhost!也就是说cargo.tomcat.manager.url里配置了什么都是不起作用的。端口也一样,要配置。
如果服务器上已运行了部署项目,必须mvn cargo:redeploy启动,用mvn cargo:deploy会报错Error writing request body to server
如果出现The username you provided is not allowed to use the text-based Tomcat Manager (error 403)错误,必须把tomcat7部署用户的权限定义为“manager-script”,才可以成功部署。
Encountered exception javax.management.RuntimeErrorException: Error invoking method check,缺少manager-jmx权限
manager-gui — Access to the HTML interface.
manager-status — Access to the "Server Status" page only.
manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
manager-jmx — Access to JMX proxy interface and to the "Server Status" page.