您的位置:首页 > Web前端

解决maven deploy时报401 ReasonPhrase: Unauthorized 错误

2017-06-21 11:41 453 查看
详细报错信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project duy-user: Failed to deploy artifacts: Could not transfer artifact com.dopp.voor:duy-user:pom:1.31.0-20170620.020558-8 from/to snapshots (http://dev-mvn.***.com/content/repositories/snapshots/):
Failed to transfer file: http://dev-mvn.***.com/content/repositories/snapshots/com/dopp/voor/duy-user/1.31.0-SNAPSHOT/duy-user-1.31.0-20170620.020558-8.pom. 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
关键错误信息1: Failed to deploy artifacts

关键错误信息2: Could not transfer artifact com.*:*:pom:* from/to snapshots (http://dev-mvn.***.com/content/repositories/snapshots/)

关键错误信息3: Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

提取关键错误信息:Could not transfer …… from/to snapshots …… Return code is: 401, ReasonPhrase: Unauthorized.

很明显了,deploy的时候,权限不够大。于是排查maven setting配置文件,最终在<servers>……</servers>配置节点中增加如下配置,问题解决:

解决问题:
<server>

    <id>snapshots</id>

    <username>deployment</username>

    <password>l****11</password>

</server>
参考信息:

<!--配置服务端的一些设置。一些设置如安全证书不应该和pom.xml一起分发。这种类型的信息应该存在于构建服务器上的settings.xml文件中。-->
<servers>
<!--服务器元素包含配置服务器时需要的信息 -->
<server>
<!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。-->
<id>snapshots</id>
<!--鉴权用户名。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。 -->
<username>my_login</username>
<!--鉴权密码 。鉴权用户名和鉴权密码表示服务器认证所需要的登录名和密码。密码加密功能已被添加到2.1.0 +。详情请访问密码加密页面-->
<password>my_password</password>
<!--鉴权时使用的私钥位置。和前两个元素类似,私钥位置和私钥密码指定了一个私钥的路径(默认是${user.home}/.ssh/id_dsa)以及如果需要的话,一个密语。将来passphrase和password元素可能会被提取到外部,但目前它们必须在settings.xml文件以纯文本的形式声明。 -->
<privateKey>${usr.home}/.ssh/id_dsa</privateKey>
<!--鉴权时使用的私钥密码。-->
<passphrase>some_passphrase</passphrase>
<!--文件被创建时的权限。如果在部署的时候会创建一个仓库文件或者目录,这时候就可以使用权限(permission)。这两个元素合法的值是一个三位数字,其对应了unix文件系统的权限,如664,或者775。 -->
<filePermissions>664</filePermissions>
<!--目录被创建时的权限。 -->
<directoryPermissions>775</directoryPermissions>
</server>
</servers>

解决这个问题最关键要明白,下面配置的作用。

<!--服务器元素包含配置服务器时需要的信息 -->

  <server>

   <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。-->

   <id>snapshots</id>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐