tomcat-maven-plugin:服务器返回HTTP响应代码:403 [英] tomcat-maven-plugin: Server returned HTTP response code: 403
问题描述
我试图自动将Eclipse Java EE中的Maven Webapp部署到我的本地Tomcat服务器。我使用的是Windows XP。这是错误:
I'm trying to automatically deploy a Maven webapp from Eclipse Java EE to my local Tomcat server. I'm using Windows XP. This is the error:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project practicaIW: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://127.0.0.1:8080/manager/deploy?path=%2Fpractica-3&war= -> [Help 1]
我想我知道这个错误的原因:
I think I know the reason of this error:
- 如果我在eclipse中运行Tomcat服务器,127.0.0.1:8080是我的工作区/目标。有任何管理器文件夹和其余的类,所以它不工作。可能的困扰解决方案:将此文件夹和文件复制到我的项目中。
- 如果我在eclipse之外运行Tomcat服务器,127.0.0.1:8080是tomcat_location / webapps。它不起作用,因为Eclipse在我的工作区中创建了war文件,因此Tomcat找不到它。可能的解决方案:配置maven-war-plugin将战争文件创建到127.0.0.1:8080。我该怎么做?是否是最好的方法?
- If I run the Tomcat server inside eclipse, 127.0.0.1:8080 is my workspace/target. There is any manager folder and rest of classes on it, so it does not work. Possible botched solution: copy this folder and files inside my project.
- If I run the Tomcat server outside eclipse, 127.0.0.1:8080 is tomcat_location/webapps. It does not work because Eclipse creates the war file in my workspace so Tomcat cannot find it. Possible solution: configure the maven-war-plugin to create the war file into 127.0.0.1:8080. How could I do it? Is it the best way to procceed?
pom.xml提取:
pom.xml extract:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<username>admin</username>
<password>password</password>
<server>TomcatServer</server>
<path>/practica-3</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
tomcat-users.xml提取:
tomcat-users.xml extract:
<tomcat-users>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="admin"/>
<role rolename="manager-script"/>
<user password="password" roles="admin,manager,manager-gui,manager-script" username="admin"/>
</tomcat-users>
更新:
pvm14回答了这个问题。但是以前你必须打开文件:Tomcat v7.0 Server在localhost.server。以下是如何:
UPDATE: pvm14 answered the question. But previously you have to open the file: Tomcat v7.0 Server at localhost.server. Here is how:
- 属性
- 点击开关位置,箭头3指示的文件将出现
- 打开文件
推荐答案
从Eclipse内部启动的Tomcat服务器不会有 Tomcat Manager的控制台(localhost:8080 / manager)除非您使用此选项进行配置:
The Tomcat server you start from inside Eclipse isn't going to have a 'Tomcat Manager' console available (localhost:8080/manager) unless you configure it with this option:
这意味着您从Eclipse启动的Tomcat与您在定义Tomcat服务器时提供的完全一致在IDE中。否则,Eclipse将在工作空间内的目录中运行一个没有管理员的修剪版本:
This means that the Tomcat you start from Eclipse is exactly the one you provided when defining the Tomcat server in the IDE. Otherwise Eclipse runs a pruned version, without manager available, in a directory located inside the workspace:
{workspace_dir}\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
如果你在您运行的实例中没有一个tomcat管理器tomcat-maven-plugin将无法部署任何内容
If you don't have a tomcat manager available in the instance you're running tomcat-maven-plugin won't be able to deploy anything
最好的问候
这篇关于tomcat-maven-plugin:服务器返回HTTP响应代码:403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!