Maven未经授权,ReasonPhrase:未经授权 [英] Maven Not authorized , ReasonPhrase:Unauthorized

查看:154
本文介绍了Maven未经授权,ReasonPhrase:未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Nexus存储库中检出我的代码. 首先,我用

I am trying to check out my code from Nexus repository. First of all, I've generate the password with

mvn --encrypt-master-password _mypassword_

这是我的c:/Users/joanet/.m2/settings-security.xml:

This is my c:/Users/joanet/.m2/settings-security.xml :

<settingsSecurity>
<master>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED2ws=}</master>
</settingsSecurity>

这是我的c:/progs/PGM/apache-maven-3.0.5/conf/settings.xml

and this is my c:/progs/PGM/apache-maven-3.0.5/conf/settings.xml

  <?xml version="1.0" encoding="UTF-8"?>

    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
    license agreements. See the NOTICE file distributed with this work for additional
    information regarding copyright ownership. The ASF licenses this file to
    you under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
    by applicable law or agreed to in writing, software distributed under the
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
    OF ANY KIND, either express or implied. See the License for the specific
    language governing permissions and limitations under the License. -->

    <!-- http://maven.apache.org/settings.html -->
    <settings xmlns="http://maven.apache.org/settings/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <localRepository>C:/Users/joanet/.m2/repository</localRepository>


    <proxies>
     <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>joanet</username>
      <password>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED5ws=}</password>
      <host>157.129.133.11</host>
      <port>8032</port>
      <nonProxyHosts>localhost</nonProxyHosts>
     </proxy>
    </proxies>

    <servers>
      <server>
       <id>ecPublicRepository</id>
       <username>joanet</username>
       <password>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED5ws=}</password>
      </server>


    </servers>

    <mirrors></mirrors>

    <pluginGroups>
     <!-- pluginGroup Specifies a further group identifier to use for plugin lookup.  -->
     <pluginGroup>com.oracle.weblogic</pluginGroup>
     <pluginGroup>com.github.searls</pluginGroup>
     <pluginGroup>com.cj.jshintmojo</pluginGroup>
     <pluginGroup>com.github.phasebash</pluginGroup>

    </pluginGroups>

    <profiles>
     <profile>
      <id>activeProfile</id>

      <repositories>

       <repository>
          <id>ecPublicRepository</id>
          <url>https://foo.com/nexus/content/groups/public/</url>
       </repository>


      </repositories>

      <pluginRepositories>

       <pluginRepository>
        <id>PublicRepository</id>
        <name>Public Repository</name>
        <url>https://foo.com/nexus/content/groups/public/</url>
       </pluginRepository>
      </pluginRepositories>

     </profile>

    </profiles>

    <!-- activeProfiles | List of profiles that are active for all builds. | -->
    <activeProfiles>
     <activeProfile>activeProfile</activeProfile>
    </activeProfiles>


    </settings>

但这是错误:

Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not
 transfer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.3.1 from/
to ecPublicRepository (https://foo.com/nexus/content/groups/public/): Not authorized , ReasonPhrase:Unauthorized.
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
facts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
fact(DefaultArtifactResolver.java:193)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:281)
        ... 28 more

推荐答案

在对主密码进行加密之后,您还应该对连接所需的实际密码进行加密.因此,settings-security.xml中的哈希值应该与您在服务器配置中使用的实际值不同.

After you encrypt your master password, you should also encrypt the actual password you need for nexus. So the hashed value in the settings-security.xml should be different then the actual values you use in the server configurations.

您可以按照以下步骤操作(取自此处):

You can follow these steps (taken from here):

使用以下命令行:

Use the following command line:

mvn --encrypt-master-password <password>

注意:从Maven 3.2.1开始,密码是一个可选参数.如果未提供,Maven将提示您输入密码.较早版本的Maven不会提示您输入密码,因此必须在命令行上以纯文本形式键入密码.有关更多信息,请参见下面的提示.

Note: Since Maven 3.2.1 the password is an optional argument. If not provided, Maven will prompt for the password. Earlier versions of Maven will not prompt for a password, so it must be typed on the command-line in plaintext. See Tips below for more information.

此命令将生成密码的加密版本,例如

This command will produce an encrypted version of the password, something like

{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}

将此密码存储在〜/.m2/settings-security.xml中;看起来应该像

Store this password in the ~/.m2/settings-security.xml; it should look like

<settingsSecurity>
<master>{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master>
</settingsSecurity>

完成后,您可以开始加密现有服务器密码. 如何加密服务器密码

When this is done, you can start encrypting existing server passwords. How to encrypt server passwords

您将必须使用以下命令行:

You will have to use the following command line:

mvn --encrypt-password <password>

注意:就像--encrypt-master-password一样,自Maven 3.2.1起,password参数是可选的.

Note:Just like --encrypt-master-password the password argument is optional since Maven 3.2.1.

此命令将生成它的加密版本,例如

This command will produce an encrypted version of it, something like

{COQLCE6DU6GtcS5P=}

将其剪切-粘贴到服务器部分的settings.xml文件中.看起来像这样:

Cut-n-paste it into your settings.xml file in the server section. This will look like:

<settings>
...
<servers>
...
<server>
<id>my.server</id>
<username>foo</username>
<password>{COQLCE6DU6GtcS5P=}</password>
</server>
...
</servers>
...
</settings>

请注意,密码可以包含大括号之外的任何信息,因此以下内容仍然有效:

Please note that password can contain any information outside of the curly brackets, so that the following will still work:

这篇关于Maven未经授权,ReasonPhrase:未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆