记录
最近在配置tomcat折腾了一翻后终于通了,因此需要记录下。
通过maven打包的war包自动上传到tomcat上。新的tomcat有了少许变动,导致一开始不停的会出现403 Access Denied。
现在我把我的配置留下。
tomcat7配置
在tomcat中主要配置用户权限,在上传war包的时候,是需要使用app manager来进行的。
因此需要先配置manager的权限。
在最新的tomcat中不允许使用模糊权限。
- Users with the manager-gui role should not be granted either the manager-script or manager-jmx roles.
- If the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.
因此配置的时候需要区分manager-gui和manager-script,其中
manager-script 是用来上传war的
manager-gui是用来访问http://127.0.0.1:8080/manager/html
第一步
先给tomcat 在conf/tomcat-users.xml中进行如下配置,将权限和角色分离。
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
<role rolename="manager-script"/>
<username="deploy" password="123456" roles="manager-script"/>
第二步
配置自己工程的pom.xml。 配置需要上传的路径
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!--使用manager的上传地址-->
<url>http://127.0.0.1:8080/manager/text</url>
<!--工程的名字-->
<path>/test</path>
<username>deploy</username>
<password>123456</password>
</configuration>
</plugin>
第三步
mvn tomcat7:deploy