maven私服deploy时报Return code is: 401, ReasonPhrase: Unauthorized

今天deploy一个jar包到私服上时,一直报错,原因一大串:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project ussp-common-parent: Failed to deploy artifacts: Could not transfer artifact com.ussp.common:ussp-common-parent:pom:1.0.0-20190214.060901-540 from/to snapshots (http://192.168.1.45:8081/nexus/content/repositories/snapshots/): Failed to transfer file: http://192.168.1.45:8081/nexus/content/repositories/snapshots/com/ussp/common/ussp-common-parent/1.0.0-SNAPSHOT/ussp-common-parent-1.0.0-20190214.060901-540.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR] 

可以看到最后显示,返回码是401,跟授权或权限相关。可是我的settings.xml文件里面的用户权限足够,怎么还报权限不足呢?我找了一大圈,终于发现是pom.xml文件与settings.xml关于授权相关的配置没对应起来导致的,下面是我pom中的配置:

<distributionManagement>
		<repository>
			<id>releases</id>
			<name>Nexus Release Repository</name>
			<url>http://192.168.1.X:8081/nexus/content/repositories/releases/</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://192.168.1.X:8081/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
</distributionManagement>

下面是我settings.xml的配置:

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

比较可以看到 pom中repository和snapshotRepository两个库的id没有与settings.xml中对应起来。修改一致即可发布成功。

转载于:https://my.oschina.net/u/3293327/blog/3010022

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值