解决maven发布项目到nexus报Unauthorized错误

时间:2026-02-14 04:05:49

1、首先找到maven的setting.xml配置文件,maven的conf里的是全局的,一般我们建议修改用户目录下面的配置文件

解决maven发布项目到nexus报Unauthorized错误

2、在maven的settings.xml文件中添加服务器配置,仓库id、用户名和密码,id需要与上面pom.xml中的仓库id一致

<servers>

         <server>

                   <id>releases</id>

                   <username>admin</username>

                   <password>xxx</password>

         </server>

         <server>

                   <id>snapshots</id>

                   <username>admin</username>

                   <password>xxx</password>

         </server>

</servers>

3、在项目pom.xml中文件中的仓库配置

<distributionManagement>

         <repository>

                   <id>releases</id>

                   <name>Nexus Release Repository</name>

                   <url>http://192.168.10.6:8081/nexus/content/repositories/releases/</url>

         </repository>

         <snapshotRepository>

                   <id>snapshots</id>

                   <name>Nexus Snapshot Repository</name>

                   <url>http://192.168.10.6:8081/nexus/content/repositories/snapshots/</url>

         </snapshotRepository>

</distributionManagement>

4、再执行mvn deploy,就不会报Unauthorized错误

© 2026 长短途
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com