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

App*_*sei 10 tomcat spring-mvc m2eclipse maven

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

Maven部署错误:

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

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

Tomcat的users.xml中

<role rolename="admin"/>
  <role rolename="manager"/>
  <user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)

更多信息:

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

这对我有用

<role rolename="manager-script"/>
<role rolename="admin-script"/>
<user password="password" roles="manager-script,admin-script" username="admin"/>
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)

Rob*_*rop 6

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

切换您pom.xml<password>admin</password>.

此外,根据Tomcat文档,管理员用户需要更改角色.您将希望manager-gui角色访问HTML管理器和管理器脚本角色以访问文本界面.

  • 我认为这里的问题是角色名称不太正确.Tomcat 7.0文档声明,要访问基于文本的管理器API,用户需要具有manager-script角色. (2认同)