Tomcat conf 下的tomcat-users.xml 增加
<role rolename="manager"/> <role rolename="admin"/> <role rolename="manager-gui"/> <user username = "admin" password = "password" roles = "admin,manager,manager-gui,manager-script,manager-jmx,manager-status" />
启动tomcat7,然后访问 http://localhost:8080/manager/html,输入admin/password,如果出现以下界面,表示tomcat一切OK
如果是Tomcat6 http://localhost:8080/manager
在Maven的conf目录中的setting.xml servers节点增加
<server> <id>healthpad</id> <username>admin</username> <password>admin</password> </server>
修改pom.xml
<plugin> <!--结果证明属性这个可以不设--> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <packagingExcludes>WEB-INF/web.xml</packagingExcludes> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <url>http://localhost:8080/manager/html</url> <server>healthpad</server> <username>admin</username> <password>admin</password> </configuration> </plugin>
Tomcat6 在Url中输入 http://localhost:8080/manager
右击Java项目,运行 输入 在Goals中添加:clean install tomcat:redeploy
异常解决
Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project healthpad:Cannot invoke Tomcat manager:Server returned HTTP response code:401for URL: http://localhost:8080/manager/html/deploy?path=%2FmkyWebApp&war= -> [Help 1]
这种问题在 pom.xml中增加 username password
<configuration>
<url>http://localhost:8080/manager</url> <!--tomcat7加/html-->
<server>cad</server>
<username>admin</username>
<password>admin</password>
</configuration>
如果是403,请手工在浏览器中访问
http://localhost:8080/manager/html/deploy 调整 tomcat下的tomcat-users.xml 角色权限