401(未经授权)使用maven将war部署到远程Tomcat 8时出错[英] 401 (Unauthorized) error while using maven to deploy war to remote Tomcat 8

问题描述

我正在尝试在远程 Tomcat 8 上部署战争,但在此过程中出现 401(未授权)错误.

错误日志

[ERROR] Tomcat return http status error: 401, Reason Phrase: Unauthorized

为部署执行的命令

mvn tomcat7:redeploy

pom.xml

<properties>
    <integration.tomcat.url>http://gsi-547576:8080/manager/text</integration.tomcat.url>
</properties>

<!-- Deploy to Remote Tomcat -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>${integration.tomcat.url}</url>
                <server>integration-tomcat</server>
                <path>/${project.artifactId}</path>
            </configuration>
        </plugin>

tomcat-users.xml

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

请指导.

推荐答案

您需要为"integration-tomcat"服务器定义凭据;这通常在您的 ~/.m2/settings.xml 文件中完成:

<servers>
  <server>
    <id>integration-tomcat</id>
    <username>manager</username>
    <password>manager</password>
  </server>
</servers>

本文地址:https://www.itbaoku.cn/post/978502.html