我有一个tomcat7。访问管理器应用程序(http:// localhost:7777 / manager / html)可以正常使用tomcat-users.xml中定义的凭据。
现在我想部署一个带有maven3的应用程序。我配置了tomcat maven插件:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<url>http://localhost:7777/manager</url>
<server>localhost7777</server>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<url>http://localhost:7777/manager</url>
<server>localhost7777</server>
</configuration>
</plugin>
在mavens setting.xml中,我添加了服务器的条目:
<servers>
<server>
<id>localhost7777</id>
<username>manager</username>
<password>secret</password>
</server>
</servers>
现在应用程序将成功构建。但是tomcat7:deploy的目标会导致来自tomcat的访问被拒绝错误消息:
...
[INFO] Deploying war to http://localhost:7777/workload-monitor
Uploading: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true
Uploaded: http://localhost:7777/manager/deploy?path=%2Fworkload-monitor&update=true (2329 KB at 55435.1 KB/sec)
[INFO] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[INFO] <html>
[INFO] <head>
[INFO] <title>403 Access Denied</title>
[INFO] <style type="text/css">
[INFO] <!--
...
有人可以给我一个暗示吗?
答案 0 :(得分:19)
为了跟进这个问题,我实际上遇到了这个问题,我最近设置了我的ubuntu框,我的解决方案,而不是/ html实际上是指向/ text:代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<username>admin</username>
<password>admin</password>
</configuration>
</plugin>
答案 1 :(得分:3)
http://mycodenotes.wordpress.com/2011/01/25/mvn-tomcatdeploy-to-tomcat-7/中描述的解决方案为我工作。
mvn插件tomcat-maven-plugin与tomcat 5.5一起工作正常,但是当你尝试部署到tomcat 7实例时它会出现403错误。原来tomcat 7改变了部署的URL,所以你需要配置插件来使用这个不同的url。您可以使用以下插件配置执行此操作:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
</configuration>
</plugin>
神奇的是现在使用/ manager / html的URL设置,而不是/ manager的默认网址。此信息的原始来源:http://www.jroller.com/Fabszn/entry/tomcat_7_et_le_plugin
答案 2 :(得分:1)
虽然不是问题的答案,但问题似乎是由于tomcat:deploy
尝试将webapp部署到http://localhost:7777/manager/deploy
而tomcat7,部署网址为http://localhost:777/manager/html/deploy
这一事实。似乎没有办法将其指定为插件配置。
答案 3 :(得分:0)
使用以下设置:
MAVEN_HOME / CONF / settings.xml中:
<server>
<id>myTomcat</id>
<username>admin</username>
<password>admin</password>
</server>
TOMCAT_HOME / CONF / Tomcat的users.xml中:
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script" />
的pom.xml:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<server>myTomcat</server>
<url>http://localhost:8080/manager/text</url>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
部署:
mvn clean install tomcat7:redeploy