maven deploy到nexus报错:Return code is: 401

来源:互联网 发布:rsa加密算法c语言实现 编辑:程序博客网 时间:2024/05/22 14:40

错误代码:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project parent: Failed to deploy artifacts: Could not transfer artifact com.mingxungu.parent:parent:jar:0.0.1-20170620.011033-2 from/to snapshots (http://127.0.0.1:8081/nexus/content/repositories/snapshots/): Failed to transfer file: http://127.0.0.1:8081/nexus/content/repositories/snapshots/com/mingxungu/parent/parent/0.0.1-SNAPSHOT/parent-0.0.1-20170620.011033-2.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [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/MojoExecutionException

原因:

可能是:401没有配置认证。

在maven目录conf的setting.xml里,配置

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

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

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

  <!-- 私服上仓库地址 -->  <distributionManagement>  <repository>  <id>releases</id>  <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>  </repository>  <snapshotRepository>  <id>snapshots</id>  <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>  </snapshotRepository>  </distributionManagement>

运行deploy时还报错,查看eclipse的maven配置,将代码配置在User Settings的目录下,而不是Global Settings



 
阅读全文
1 0