java 打包 mvn clean package时 "401 Unauthorized and 'parent.relativePath' points at wrong local POM"

在虚拟机上单独拉取一个项目进行打包时出现如下错误

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.gbx:spring-cloud-demo-config:1.0.0-SNAPSHOT:
 Could not transfer artifact com.gbx:spring-cloud-demo-dependencies:pom:1.0.0-SNAPSHOT from/to nexus (http://192.168.73.132:8081/repository/maven-public/): 
Authentication failed for http://192.168.73.132:8081/repository/maven-public/com/gbx/spring-cloud-demo-dependencies/1.0.0-SNAPSHOT/spring-cloud-demo-dependencies-1.0.0-SNAPSHOT.pom 
401 Unauthorized and 'parent.relativePath' points at wrong local POM @ line 6, column 13

原因是因为寻找parent依赖出错,可是我已经把依赖部署到了nexus私服里了,突然想起nexus私服账户没有在虚拟机里设置(

(lll¬ω¬) )!

在maven的settings.xml中<servers>节点下设置你的nexus私服账户

vi /usr/local/maven/apache-maven-3.6.3/conf/settings.xml

 此处id要与你pom中引用的id一致,账号密码同步于你自己的nexus私服

     <server>
	  <id>nexus</id>
	  <username>admin</username>
	  <password>123456</password>
	</server>
	
	<server>
	  <id>nexus-releases</id>
	  <username>admin</username>
	  <password>123456</password>
	</server>

	<server>
	  <id>nexus-snapshots</id>
	  <username>admin</username>
	  <password>123456</password>
	</server>

相应的pom文件中应有此处nexus私服配置

<repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>http://192.168.73.132:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值