You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署至GitLab Maven仓库时遭遇401 Unauthorized错误求助

求助:Maven部署Jar包到GitLab Maven仓库报401 Unauthorized错误

本地尝试将Jar包部署到公司GitLab的项目Maven仓库时,一直报401未授权错误,找不到原因,求帮忙排查。

环境信息

  • Maven版本:3.9.4
  • GitLab版本:v17.7.1-ee

执行的部署命令

C:\Users\jim\Desktop\upload-test>mvn deploy:deploy-file -DpomFile="pom.xml" -DgroupId="com.wibu" -DartifactId=codemeter -Dversion="8.20" -Dpackaging="jar" -Dfile="CodeMeter.jar" -DrepositoryId="gitlab-maven" -Durl="https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven/" -Dauthentication.username="jim" -Dauthentication.password="glpat-my_acc_token_here"

报错信息

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.wibu:codemeter >-------------------------
[INFO] Building codemeter 8.20
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- deploy:3.1.1:deploy-file (default-cli) @ codemeter ---
Uploading to gitlab-maven: https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven/com/wibu/codemeter/8.20/codemeter-8.20.jar
Uploading to gitlab-maven: https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven/com/wibu/codemeter/8.20/codemeter-8.20.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.633 s
[INFO] Finished at: 2025-01-20T17:13:16-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy-file (default-cli) @ codemeter: Failed to deploy artifacts: Could not transfer artifact com.wibu:codemeter:jar:8.20 from/to gitlab-maven (https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven/): status code: 401, reason phrase: Unauthorized (401) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[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

settings.xml配置

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  
  <proxies>
    <proxy>
      <id>appgate-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>localhost</host>
      <port>3128</port>
    </proxy>
  </proxies>

  <servers>
    <server>
      <id>gitlab-maven</id>
      <configuration>
        <httpHeaders>
          <property>
            <name>jim</name>
            <value>glpat-my_token_here</value>
          </property>
        </httpHeaders>
      </configuration>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>maven-public</id>
      <url>https://nexus.mycompany.tools/repository/maven-public</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
</settings>

pom.xml配置

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.wibu</groupId>
    <artifactId>codemeter</artifactId>
    <version>8.20</version>
    <packaging>jar</packaging>

    <repositories>
      <repository>
        <id>gitlab-maven</id>
        <url>https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven</url>
      </repository>
    </repositories>
    <distributionManagement>
      <repository>
        <id>gitlab-maven</id> 
        <url>https://gitlab.mycompany.tools/api/v4/projects/5835/packages/maven</url> 
      </repository>
      <snapshotRepository>
        <id>gitlab-maven</id>
        <url>https://gitlab.mycompany.tools/api/v4/projects/5835/packages/mavenn</url>
      </snapshotRepository>
    </distributionManagement>

</project>

内容的提问来源于stack exchange,提问作者simgineer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 19:37:15