回顾 nexus maven-snapshots 401 Unauthorized

解决Nexus Maven授权问题:配置settings.xml与pom.xml
本文介绍了如何解决Nexus私库访问时遇到的401 Unauthorized问题。关键在于正确配置Maven的settings.xml文件,包括设置私库的服务器ID、用户名和密码,以及镜像和激活配置。同时,pom.xml中也需要配置正确的repository和snapshotRepository来指定发布和快照仓库的URL。遵循这些步骤,可以确保Maven能够顺利地与Nexus私库交互。

 1. 修改maven settings 文件

私库的用户名和密码   

 <server>  
        <id>maven-releases</id>  
        <username>admin</username>  
        <password>******</password>  
    </server>  
    <server>  
        <id>maven-snapshots</id>  
        <username>admin</username>  
        <password>******</password>  
    </server> 
私库地址
<mirror>
      <id>nexus-public</id>
      <mirrorOf>*</mirrorOf>
      <url>http://*****:8081/repository/maven-public</url>
</mirror>

 <profiles> <profile>
          <id>zc</id>
          <repositories>
              <repository>
                  <id>maven-public</id>
                  <url>http://******:8081/repository/maven-public</url>
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
          </repositories>
      </profile></profiles>

    <activeProfiles>
        <activeProfile>zc</activeProfile>
    </activeProfiles>

二 pom配置

<distributionManagement>
    <repository>
        <id>maven-releases</id>
        <name>Nexus Release Repository</name>
        <url>http://******:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>maven-snapshots</id>
        <name>Nexus Snapshot Repository</name>
        <url>http://*******:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

注意,将红色标注的位置意义对应上就可以解决nexus maven-snapshots 401 Unauthorized的问题了。

参考:

nexus3 Unauthorized问题解决_hongweigg的专栏-优快云博客icon-default.png?t=M0H8https://blog.youkuaiyun.com/hongweigg/article/details/105165955搭建Nexus私库&使用_AI-优快云博客_nexus使用icon-default.png?t=M0H8https://blog.youkuaiyun.com/luozhonghua2014/article/details/81583510

Downloading from nexus-snapshots-mirror: http://192.168.101.4:8081/repository/maven-snapshots/cn/lk/cloud/lk-module-supplier-api/2.4.1-SNAPSHOT/lk-module-supplier-api-2.4.1-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for lk-module-equipment 2.4.1-SNAPSHOT: [INFO] [INFO] lk-module-equipment ................................ SUCCESS [ 0.816 s] [INFO] lk-module-equipment-api ............................ SUCCESS [ 2.871 s] [INFO] lk-module-equipment-biz ............................ FAILURE [ 6.410 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.832 s [INFO] Finished at: 2025-08-08T15:49:45+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project lk-module-equipment-biz: Could not resolve dependencies for project cn.lk.cloud:lk-module-equipment-biz:jar:2.4.1-SNAPSHOT: Failed to collect dependencies at cn.lk.cloud:lk-module-supplier-api:jar:2.4.1-SNAPSHOT: Failed to read artifact descriptor for cn.lk.cloud:lk-module-supplier-api:jar:2.4.1-SNAPSHOT: The following artifacts could not be resolved: cn.lk.cloud:lk-module-supplier-api:pom:2.4.1-SNAPSHOT (absent): Could not transfer artifact cn.lk.cloud:lk-module-supplier-api:pom:2.4.1-SNAPSHOT from/to nexus-snapshots-mirror (http://192.168.101.4:8081/repository/maven-snapshots/): Connect to 192.168.101.4:8081 [/192.168.101.4] failed: Connection refused: no further information -> [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/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <args> -rf :lk-module-equipment-biz Process finished with exit code 1
08-09
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值