1、远程tomcat配置:
Tomcat conf 下的tomcat-users.xml 增加
<tomcat-users>
<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 username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
</tomcat-users>
启动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>password</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</url> <server>healthpad</server>
<!-- setting.xml和此处可以只配置一处--> <username>admin</username> <password>password</password> </configuration> </plugin>
Tomcat6 在Url中输入 http://localhost:8080/manager
允许maven命令:
1、clean install
2、tomcat:deploy/redeploy(如果是第一次部署,执行tomcat:deploy)
异常解决
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]
这种问题先确保tomcat里的manager项目正常允许着,然后在 pom.xml中增加 username password
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>healthpad</server>
<username>admin</username>
<password>password</password>
</configuration>