Tomcat-Maven 401错误:无法调用Tomcat管理器

时间:2012-10-05 20:26:37

标签: tomcat maven spring-mvc m2eclipse

完成StackOverFlow中显示的大多数错误仍然无法解决。我正在尝试部署SpringMVC应用程序。但是,我无法让它发挥作用。

Maven Deploy错误:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project productmgmt: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/deploy?path=%2Fproductmgmt&war=&update=true -> [Help 1]

的pom.xml:

<build>
        <finalName>productmgmt</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <path>/productmgmt</path>
                    <username>admin</username>
                    <password>password</password>
                </configuration>
            </plugin>
        </plugins>
    </build>

Tomcat的users.xml中

<role rolename="admin"/>
  <role rolename="manager"/>
  <user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>

更多信息:

[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这对我有用

<role rolename="manager-script"/>
<role rolename="admin-script"/>
<user password="password" roles="manager-script,admin-script" username="admin"/>
</tomcat-users>

1 个答案:

答案 0 :(得分:6)

您的maven配置的用户名和密码设置为admin/password。在Tomcat配置中,它们设置为admin/admin

将您的pom.xml切换为<password>admin</password>

此外,根据Tomcat docs,管理员用户需要更改角色。您需要 manager-gui 角色来访问HTML管理器和 manager-script 角色才能访问文本界面。