【问题标题】:Maven - Error code 401, UnauthorizedMaven - 错误代码 401,未经授权
【发布时间】:2015-12-11 17:38:17
【问题描述】:

我刚刚在我的 Eclipse IDE 中导入了一些 maven 项目。 但是我在 Eclipse 项目中有这个错误:

Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from https://intra.telecom.fr/CITnet/nexus/content/groups/public/ was cached in the local repository, 
resolution will not be reattempted until the update interval of ecPublicRepository has elapsed or updates are forced. 
Original error: 
Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to ecPublicRepository
 (https://intra.telecom.fr/CITnet/nexus/content/groups/public/): 
Access denied to https://intra.telecom.fr/CITnet/nexus/content/groups/public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom. 
Error code 401, Unauthorized    pom.xml 

但我已经定义了对网站 intra.telecom.fr 的访问权限 在文件 C:\développement\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>{yRso+k6+abkHTVcPc5esNgartpDSfHPWgHL/QvhQ33c=}</password>
  <host>168.168.141.12</host>
  <port>7022</port>
  <nonProxyHosts>localhost|intra.telecom.fr</nonProxyHosts>
 </proxy>
</proxies>

<servers>
  <server>
   <id>ecPublicRepository</id>
   <username>joanet</username>
   <password>{yRso+k6+abkHTVcPc5esNgartpDSfHPWgHL/QvhQ57c=}</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://intra.telecom.fr/CITnet/nexus/content/groups/public/</url>
   </repository>


  </repositories>

  <pluginRepositories>

   <pluginRepository>
    <id>ecPublicRepository</id>
    <name>EC Public Repository</name>
    <url>https://intra.telecom.fr/CITnet/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>

【问题讨论】:

  • 你确定你可以在没有代理的情况下访问intra.telecom.fr吗??
  • 我建议在yourUserHomeDir/.m2 中创建一个settings.xml 文件并在其中添加所有特定设置,而不是修改Maven 附带的settings.xml。 Eclipse 可能正在使用不同的 Maven 安装。如果您将自定义设置在 yourUserHomeDir/.m2/settings.xml 中,Eclipse 和其他 Maven 安装可能都会找到它们。

标签: java maven


【解决方案1】:

使用命令加密你的主密码并将其放入~/.m2/settings-security.xml

mvn --encrypt-master-password  <your_master_pass>

将加密的主密码放入~/.m2/settings-security.xml。 例如,如果你得到字符串{p123=},文件内容将是

<settingsSecurity>
  <master>{p123=}</master>
</settingsSecurity>

通过运行以下命令加密您的 Maven 存储库密码: mvn --encrypt-password &lt;your_repo_pass&gt; 并创建 ~/.m2/settings.xml,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <servers>
      <server>
        <id>id</id>
        <username>username</username>
        <password>{hashed-passwd}</password>
      </server>
   </servers>
</settings>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-20
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    相关资源
    最近更新 更多