5

我将 Tomcat 7 作为 Windows 服务运行。我想在我的项目根目录中执行 mvn:tomcat deploy 。

但是这个错误一直出现,你能帮我解决这个问题吗?

[INFO] Deploying war to http://localhost:8080/opendata
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.493s
[INFO] Finished at: Sun Jan 20 18:48:30 CET 2013
[INFO] Final Memory: 15M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project opendata: Cannot invoke Tomcat manager: Server returned
 HTTP response code: 405 for URL: http://localhost:8080/manager/deploy?path=%2Fo
pendata&war= -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

我的 pom 文件中有以下部分:

<build>
        <finalName>opendata</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <server>myserver</server>
                </configuration>
                <version>1.1</version>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
4

2 回答 2

4

要让它发挥作用,需要做两件事;

  • 在 tomcat-users.xml 中具有角色 manager-script 的 tomcat 用户
  • 将用于部署的 url 指定为以 manager/text 结尾的内容。

而已。请参阅下面的 pom.xml 示例 conf。并且不要忘记使用 tomcat7:redeploy 这样您就不必循环取消部署/部署。

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://your-server:8080/manager/text</url>
        <username>a-username</username>
        <password>a-password</password>
        <path>/a-path</path>
    </configuration>
</plugin>
于 2014-05-26T12:23:22.873 回答
1

我今天遇到了类似的问题 - 405 错误可能是由于 Tomcat 不接受 PUT 请求引起的。这可以通过配置 Tomcat 的 web.xml(通常在 中找到%TOMCAT%\conf\web.xml)并添加以下 init-param 来实现:

<init-param>
    <param-name>readonly</param-name>
    <param-value>false</param-value>
</init-param>

您可能还需要将管理员用户添加到 tomcat-users.xml。有关更多详细信息,请参见此处

于 2013-10-31T13:05:42.007 回答