maven deploy到nexus报错:Return code is: 401, ReasonPhrase:Unauthorized

eclipse中使用clean deploy 命令,将本地文件推送到nexus时候报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file: http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client* /1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原来是没有配置认证。


maven目录conf的setting.xml里,

[quote]<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers> [/quote]

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

<!-- 配置远程发布到私服,mvn deploy -->  
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>


如果这里不配置,会报错:
报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

参考:http://blog.csdn.net/happyteafriends/article/details/8174110
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值