maven - 不能做 mvn tomcat :deploy because of http response 405

标签 maven tomcat tomcat7 maven-plugin

我将 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

我的 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>

最佳答案

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

  • 在 tomcat-users.xml 中具有角色管理器脚本的 tomcat 用户
  • 指定用于部署到以 manager/text 结尾的内容的 url。

就是这样。请参阅下面的 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>

关于maven - 不能做 mvn tomcat :deploy because of http response 405,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14427351/

相关文章:

maven - Sling 部署内容并使用 Maven 进行捆绑

eclipse - Eclipse 中 Maven Spring Boot 项目的部署程序集

java - Tomcat 8 将连字符转换为 URL 中的 %2D

tomcat - 如何配置 struts2 与 tomcat 和 apache 与 mod_jk?

postgresql - 从tomcat连接池和JPA中提取postgres连接对象

maven - 是否可以使用maven buildnumber插件生成内部版本号而无需任何scm检查?

java - 从 Maven 获取 ${basedir} 的父目录

java - 使用 Jersey 和 Tomcat 设置 Jackson 2

java - 为什么仅在生产环境中针对 Autowire 问题进行 Spring 循环引用?

spring-mvc - WAR 文件不会在 Tomcat 7 上启动