由于http响应405而无法执行mvn tomcat:deploy

kra*_*moe 5 tomcat maven-plugin maven tomcat7

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

但是,始终会出现此错误,您能帮我解决这个问题吗?

[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
Run Code Online (Sandbox Code Playgroud)

我的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>
Run Code Online (Sandbox Code Playgroud)

Fae*_*rox 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>
Run Code Online (Sandbox Code Playgroud)

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