【问题标题】:401 (Unauthorized) error while using maven to deploy war to remote Tomcat 8使用maven将war部署到远程Tomcat 8时出现401(未经授权)错误
【发布时间】:2014-10-01 20:51:47
【问题描述】:

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

请指导。

【问题讨论】:

    标签: java maven tomcat


    【解决方案1】:

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

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

    【讨论】:

    【解决方案2】:

    如果这对将来的某人有所帮助,我发现如果 tomcat-users.xml 中的密码以数字而不是字母开头,Tomcat 将返回 401。只有在尝试通过 curl 或使用 cargo maven 插件通过 GitLab 进行部署时才会出现这种情况。 (从 Eclipse 中运行 maven 部署运行良好)。

    将密码更改为以字母开头,修复了 curl 和从 GitLab 部署时的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 2014-11-03
      • 1970-01-01
      • 2020-11-15
      相关资源
      最近更新 更多