一、Tomcat6, Tomcat7中为了更好,更精确的实现权限控制,引入了多个用户角色,如manager-ui:用于查看HTML页面, 用于查看test的manager-script等。
- <role?rolename="manager"/>??
- <role?rolename="manager-gui"/>??
- <role?rolename="admin"/>??
- <role?rolename="admin-gui"/>??
- <user?username="tomcat"?password="tomcat"?roles="admin-gui,admin,manager-gui,manager"/>
二、Tomcat7中部署后的url为:
/manager/html???????? HTML的GUI界面
/manager/text????????? 文本接口
/manager/jmxproxy??????? JMX的代理
/manager/status??????????? 与状态相关的页面
三、 在Marven的settings.xml <servers>结点下加入
???<server>
????? <id>tomcat</id>
????? <username>admin</username>
????? <password>admin</password>
??? </server>
四、如果在tomcat的conf中这样配置tomcat-users.xml 就会出现403 Access Deny
? <role rolename="manager-ui"/>
? <user username="tomcat" password="1q2w3e4r" roles="manager-ui" />
改成如下配置即可避免403 Access Deny的错误:
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-script,manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-script,manager-gui"/>
五、在Eclipse的pom.xml的plugins中加入
<plugin>
??????? <groupId>oorg.apache.tomcat.maven</groupId>
??????? <artifactId>tomcat7-maven-plugin</artifactId>
??????? <version>1.1</version>
????<configuration>
????<url>http://localhost:8080/manager/text</url>
????<server>tomcat</server>
????<username>admin</username>
????<password>admin</password>
????</configuration>
????? </plugin>
??????? <groupId>oorg.apache.tomcat.maven</groupId>
??????? <artifactId>tomcat7-maven-plugin</artifactId>
??????? <version>1.1</version>
????<configuration>
????<url>http://localhost:8080/manager/text</url>
????<server>tomcat</server>
????<username>admin</username>
????<password>admin</password>
????</configuration>
????? </plugin>
或者
<plugin>
??????? <groupId>org.codehaus.mojo</groupId>
??????? <artifactId>tomcat-maven-plugin</artifactId>
??????? <version>1.1</version>
????<configuration>
????<url>http://localhost:8080/manager/text</url>
????<server>tomcat</server>
????<username>admin</username>
????<password>admin</password>
????</configuration>
?</plugin>
??????? <groupId>org.codehaus.mojo</groupId>
??????? <artifactId>tomcat-maven-plugin</artifactId>
??????? <version>1.1</version>
????<configuration>
????<url>http://localhost:8080/manager/text</url>
????<server>tomcat</server>
????<username>admin</username>
????<password>admin</password>
????</configuration>
?</plugin>
五。在项目上点右键,选择run as->run Configurations,找到Marven Build结点,增加一项。
?? 在goals中输入package tomcat:redeploy
?? 注:在编译和发布过程中,可能会以遇到内存不足的情况,在JRE tab页中输入-Xms256m -Xmx1024m,具体自己调整。
?