一尘不染

使用Maven将War部署到远程Tomcat 8时出现401(未经授权)错误

tomcat

我正在尝试在远程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" />

请指导。


阅读 568

收藏
2020-06-16

共1个答案

一尘不染

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

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