为什么我得到了#34; 401 Unauthorized" Maven中的错误?

时间:2014-07-18 17:24:21

标签: java maven

为什么我会收到#34; 401 Unauthorized" Maven中的错误?

这是我在致电mvn deploy时收到的错误(底部是完整日志):

[INFO] BUILD FAILURE
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

根据sonatype support page

  

"如果您收到401,那是因为maven发送了错误的登录凭据,或根本没有凭据。"

以下是我已采取的步骤,下面是我的完整settings.xmlpom.xml个文件,以下是来自mvn deploy和{{1}的完整日志}。

任何想法都将不胜感激。我正和Maven一起撞到墙后。


我收到401错误后跟着sonatype's checklist

  

核对清单第1项登录Nexus用户界面,确保您的用户名/密码正确无误。如果您的计算机上安装了curl,您可以尝试使用...

部署工件
  • 我使用mvn deploy -e中的用户/传递成功登录和退出sonatype.org网站。
  • 尝试使用settings.xml手动部署工件,使用命令

curl

但得到了这个错误:

[C:\]curl -u MY_SONATYPE_DOT_COM_USERNAME:MY_SONATYPE_DOT_COM_PASSWORD https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.224928-1.pom --request PUT --data @pom.xml

我使用Warning: Couldn't read data from file "pom.xml", this makes an empty POST. curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. 选项再次运行它,这次只得到了这个:

-k

我之前从未使用过curl,所以我对这些信息的处理感到茫然。

  

核对清单第2项如果没有错误输出,请确保在服务器上正确配置了用户权限。确保删除刚刚创建的仓库。

我不知道" drop"手段。我相信我的权限已正确安装,因为我从sonatype收到此消息:

在过去几天通过Couldn't read data from file "pom.xml", this makes an empty POST. 成功将these items置于服务器上。

项目的设置:

project settings

  

核对清单第3项确保您已在mvn deploy中配置了服务器,并且服务器ID与pom.xml中的分发存储库ID相同。

  • settings.xml中,settings / servers / server / id等于settings.xml
  • ossrh中,distributionManagement / snapshotRepository / id等于pom.xml

(完整档案位于底部)

  

核对清单第4项确保您的settings.xml位于正确的位置(通常是_~ / .m2 / settings.xml)。您可以通过运行mvn help:effective-settings。

来检查

根据Maven的settings reference,settings.xml必须位于以下两个位置之一:

  • Maven安装:ossrh
  • 用户的安装:$M2_HOME/conf/settings.xml

这是我的设置:

  • ${user.home}/.m2/settings.xmlsettings.xml
  • C:\applications\programming\apache-maven-3.2.2\conf\settings.xmlM2_HOME

C:\applications\programming\apache-maven-3.2.2的输出:

mvn help:effective-settings
  

核对清单第5项如果服务器使用的是https,但POM中的URL是http,那么您也可以获得401.

我不明白它指的是哪个网址。

  

核对清单第6项使用最新版本的Maven,因为有一个关于401的已知问题:MNG-4469

我使用的是最新版本:

[C:\applications\utilities\curl]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:effective-settings (default-cli) @ standalone-pom ---
[INFO]
Effective user-specific configuration settings:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Generated by Maven Help Plugin on 2014-07-18T12:48:19                  -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/                -->
<!--                                                                        -->
<!-- ====================================================================== -->

<!-- ====================================================================== -->
<!--                                                                        -->
<!-- Effective Settings for 'jeffy' on 'kermit-the-frog'                    -->
<!--                                                                        -->
<!-- ====================================================================== -->

<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:sc
hemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">C:\Users\jeffy\.m2\repository</localRepository
>
  <servers xmlns="http://maven.apache.org/SETTINGS/1.1.0">
    <server>
      <username>MY_SONATYPE_DOT_COM_USERNAME</username>
      <password>***</password>
      <id>ossrh</id>
    </server>
  </servers>
  <pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0">
    <pluginGroup>org.apache.maven.plugins</pluginGroup>
    <pluginGroup>org.codehaus.mojo</pluginGroup>
  </pluginGroups>
</settings>

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.310 s
[INFO] Finished at: 2014-07-18T12:48:19-04:00
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------

------------------

完整[C:\]mvn -version Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00) Maven home: C:\applications\programming\apache-maven-3.2.2 Java version: 1.7.0_51, vendor: Oracle Corporation Java home: C:\applications\programming\jdk_7_51\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows" settings.xml个文件

(以下为pom.xmlmvn deploy的完整日志)

mvn deploy -e

settings.xml

的pom.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>ossrh</id>
       <username>MY_SONATYPE_DOT_COM_USERNAME</username>
       <password>MY_SONATYPE_DOT_COM_PASSWORD</password>
     </server>
   </servers>

   <pluginGroups></pluginGroups>
   <proxies></proxies>
   <mirrors></mirrors>
   <profiles></profiles>
</settings>

------------------

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.aliteralmind</groupId> <artifactId>xbnjava</artifactId> <packaging>pom</packaging> <version>0.1.2</version> <name>XBN-Java</name> <url>https://github.com/aliteralmind/xbnjava</url> <inceptionYear>2014</inceptionYear> <organization> <name>Jeff Epstein</name> </organization> <description>XBN-Java is a collection of generically-useful backend (server side, non-GUI) programming utilities, featuring RegexReplacer and FilteredLineIterator. XBN-Java is the foundation of Codelet (http://codelet.aliteralmind.com).</description> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>7</version> </parent> <licenses> <license> <name>Lesser General Public License (LGPL) version 3.0</name> <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> </license> <license> <name>Apache Software License (ASL) version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <developers> <developer> <name>Jeff Epstein</name> <email>aliteralmind-github@yahoo.com</email> <roles> <role>Lead Developer</role> </roles> </developer> </developers> <issueManagement> <system>GitHub Issue Tracker</system> <url>https://github.com/aliteralmind/xbnjava/issues</url> </issueManagement> <distributionManagement> <snapshotRepository> <id>ossrh</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> <scm> <connection>scm:git:git@github.com:aliteralmind/xbnjava.git</connection> <url>scm:git:git@github.com:aliteralmind/xbnjava.git</url> <developerConnection>scm:git:git@github.com:aliteralmind/xbnjava.git</developerConnection> </scm> <properties> <java.version>1.7</java.version> <jarprefix>R:\jeffy\programming\build\/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix> </properties> <!-- <profiles> <profile> <id>default-tools.jar</id> <activation> <property> <name>java.vendor</name> <value>Sun Microsystems Inc.</value> </property> </activation> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.4.2</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> </profile> </profiles> --> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>attach-artifacts</id> <phase>package</phase> <goals> <goal>attach-artifact</goal> </goals> <configuration> <artifacts> <artifact> <file>${jarprefix}-all.jar</file> <type>jar</type> </artifact> </artifacts> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <!-- This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven --> <profile> <id>release-sign-artifacts</id> <activation> <property> <name>release</name> <value>true</value> </property> </activation> </profile> </profiles> </project> mvn deploy

的完整日志

mvn deploy -e输出:

mvn deploy

(失败部分:)

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building XBN-Java 0.1.2
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava ---
[INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
[INFO] Installing R:\jeffy\programming\sandbox\z__for_git_commit_only\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.2\xbnjava-0.1.2.pom
[INFO] Installing R:\jeffy\programming\build\xbnjava-0.1.2\download\xbnjava-0.1.2-all.jar to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.2\xbnjava-0.1.2.jar
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom
2/6 KB
4/6 KB
6/6 KB

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.204 s [INFO] Finished at: 2014-07-18T11:25:17-04:00 [INFO] Final Memory: 7M/17M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.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 输出:

mvn deploy -e

(失败部分:)

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building XBN-Java 0.1.2
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava ---
[INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
[INFO] Installing R:\jeffy\programming\sandbox\z__for_git_commit_only\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.2\xbnjava-0.1.2.pom
[INFO] Installing R:\jeffy\programming\build\xbnjava-0.1.2\download\xbnjava-0.1.2-all.jar to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.2\xbnjava-0.1.2.jar
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom
2/6 KB
4/6 KB
6/6 KB

24 个答案:

答案 0 :(得分:42)

尝试将Gradle人工制品部署到Nexus Sonatype存储库时,我遇到了类似的错误。如果您提供了错误的凭据(密码等),您将收到401 Unauthorized错误。如果您尝试将某些内容发布到版本库并且该版本已存在于存储库中,那么您也会收到错误(并且我的头脑也是401)。所以您可能会发现从命令行发布它可以工作,但是当你从脚本中执行它时它会失败(因为它第一次出现在存储库中时不存在)。使用不同的版本号发布,或删除服务器上的旧文件并重新发布。

SNAPSHOTS存储库(与发布存储库相对)允许您覆盖类似编号的版本,但您的版本号应该在其末尾有“-SNAPSHOT”。

答案 1 :(得分:10)

此错误的原因之一是未指定或未正确指定repositoryId。如前所述,它应该与settings.xml中的部分相同。 几个提示...使用-e -X选项运行mvn并检查调试输出。它会告诉你它正在使用哪个repositoryId:

[DEBUG]   (f) offline = false
[DEBUG]   (f) packaging = exe
[DEBUG]   (f) pomFile = c:\temp\build-test\pom.xml
[DEBUG]   (f) project = MavenProject: org.apache.maven:standalone-pom:1 @ 
[DEBUG]   (f) repositoryId = remote-repository
[DEBUG]   (f) repositoryLayout = default
[DEBUG]   (f) retryFailedDeploymentCount = 1
[DEBUG]   (f) uniqueVersion = true
[DEBUG]   (f) updateReleaseInfo = false
[DEBUG]   (f) url = https://nexus.url.blah.com/...
[DEBUG]   (f) version = 13.1
[DEBUG] -- end configuration --

在这种情况下,它使用默认值&#34; remote-repository&#34;,这意味着出现了问题。

显然我已经指定-DrepositoryID(注释ID为大写)而不是-DrepositoryId。

答案 2 :(得分:7)

我在settings.xml中放了一个未加密的密码。

我用curl测试了这个调用

curl -u username:password http://url/artifactory/libs-snapshot-local/com/myproject/api/1.0-SNAPSHOT/api-1.0-20160128.114425-1.jar --request PUT --data target/api-1.0-SNAPSHOT.jar 

我得到了错误:

{
  "errors" : [ {
    "status" : 401,
    "message" : "Artifactory configured to accept only encrypted passwords but received a clear text password."
  } ]
}

我检索了加密密码,点击我的神器配置文件并解锁。

答案 3 :(得分:6)

只需在settings.xml中更改这些就像aliteralmind所说:

  <server>
      <id>nexus-snapshots</id>
      <username>MY_SONATYPE_DOT_COM_USERNAME</username>
      <password>MY_SONATYPE_DOT_COM_PASSWORD</password>    
 </server>

您可能需要从sonatype dot com获取用户名/密码。

答案 4 :(得分:2)

还有来自Nexus的401。尝试了上面的所有建议,但没有成功,我最终发现这是一个错误的Jenkins设置。

在失败项目的Jenkins配置中,我们在“Post Build”操作中有一个标题为“将工件部署到Maven存储库”的部分。这有一个'Repository ID'字段,它被设置为错误的值。它必须与settings.xml中的存储库ID相同,以便Jenkins读取用户和密码字段:

Jenkins Project Configuration

 <servers>
    <server>
      <id>snapshot-repository</id>  <!-- must match this -->
      <username>deployment</username>
      <password>password</password>
    </server>
  </servers>

答案 5 :(得分:2)

有些用户可能错误地输入了电子邮件地址而不是用户名。当电子邮件地址中的名称与用户名相同时,这可能会无意识地发生。

答案 6 :(得分:2)

这是sonatype nexus团队关于 401 - 未经授权

的官方解释

我建议您阅读Troubleshooting Artifact Deployment Failures以获取更多信息。

  

Code 401 - Unauthorized

     

请求或登录都没有发送登录凭据   发送了无效的凭据。检查&#34;授权   和认证&#34; Nexus UI中的系统提供可以帮助缩小范围   下。如果发送了凭证,则Feed中会有一个条目。

     

如果没有发送凭据,则可能是由于之间的不匹配造成的   您的pom的分配管理部分和您的   settings.xml的服务器部分,其中包含登录凭据。

答案 7 :(得分:1)

在我的情况下,在加密密码后,我忘记将settings-security.xml放入〜/ .m2。

答案 8 :(得分:1)

我们最近遇到过这个问题,并发现它与我们使用的Maven版本有关。我们使用3.1.0无法上传到nexus,我们一直收到401,我们又回到了3.0.3,问题就消失了。

最简单的确认方法是使用maven版本并在项目上运行“mvn deploy”。

可在此处找到更多详细信息:https://issues.apache.org/jira/browse/WAGON-421

答案 9 :(得分:1)

正如@ John的回答所述,已经存在0.1.2-SNAPSHOT的事实干扰了我的新非SNAPSHOT版本0.1.2。由于401 Unauthorized错误是模糊且无益的 - 并且通常与用户/通行证问题相关 - 因此我无法自行解决这个问题。

将版本更改为0.1.3会让我回到原来的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project xbnjava: Failed to install artifact com.github.aliteralmind:xbnjava:jar:0.1.3: R:\jeffy\programming\build\xbnjava-0.1.3\download\xbnjava-0.1.3-all.jar (The system cannot find the path specified) -> [Help 1].

一个sonatype支持人员还建议我从我的POM中移除<parent>块(它只在那里,因为它在the one from ez-vcard中,这是我开始的)并替换我的<distributionManagement>阻止

<distributionManagement>
  <snapshotRepository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </snapshotRepository>
  <repository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
  </repository>
</distributionManagement>
and then make sure that lines up with what's in your settings.xml:
<settings>
  <servers>
    <server>
      <id>ossrh</id>
      <username>your-jira-id</username>
      <password>your-jira-pwd</password>
    </server>
  </servers>
</settings>

执行此操作后,第一次运行mvn deploy实际上传了我的一个罐子!!!

输出:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XBN-Java 0.1.3
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-artifacts) @ xbnjava ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
[INFO] Installing R:\jeffy\programming\sandbox\z__for_git_commit_only\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.3\xbnjava-0.1.3.pom
[INFO] Installing R:\jeffy\programming\build\xbnjava-0.1.3\download\xbnjava-0.1.3.jar to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.3\xbnjava-0.1.3.jar
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.pom
2/6 KB
4/6 KB
6/6 KB

Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.pom (6 KB at 4.6 KB/sec)
Downloading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml
310/310 B

Downloaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml (310 B at 1.6 KB/sec)
Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml
310/310 B

Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/maven-metadata.xml (310 B at 1.4 KB/sec)
Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.jar
2/630 KB
4/630 KB
6/630 KB
8/630 KB
10/630 KB
12/630 KB
14/630 KB
...
618/630 KB
620/630 KB
622/630 KB
624/630 KB
626/630 KB
628/630 KB
630/630 KB

(成功部分:)

Uploaded: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.3/xbnjava-0.1.3.jar (630 KB at 474.7 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.632 s
[INFO] Finished at: 2014-07-18T15:09:25-04:00
[INFO] Final Memory: 6M/19M
[INFO] ------------------------------------------------------------------------

这是完整更新的POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.github.aliteralmind</groupId>
  <artifactId>xbnjava</artifactId>
  <packaging>pom</packaging>
  <version>0.1.3</version>
  <name>XBN-Java</name>
  <url>https://github.com/aliteralmind/xbnjava</url>
  <inceptionYear>2014</inceptionYear>
  <organization>
     <name>Jeff Epstein</name>
  </organization>
  <description>XBN-Java is a collection of generically-useful backend (server side, non-GUI) programming utilities, featuring RegexReplacer and FilteredLineIterator. XBN-Java is the foundation of Codelet (http://codelet.aliteralmind.com).</description>

  <licenses>
     <license>
        <name>Lesser General Public License (LGPL) version 3.0</name>
        <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url>
     </license>
     <license>
        <name>Apache Software License (ASL) version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
     </license>
  </licenses>

  <developers>
     <developer>
        <name>Jeff Epstein</name>
        <email>aliteralmind-github@yahoo.com</email>
        <roles>
           <role>Lead Developer</role>
        </roles>
     </developer>
  </developers>

  <issueManagement>
     <system>GitHub Issue Tracker</system>
     <url>https://github.com/aliteralmind/xbnjava/issues</url>
  </issueManagement>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <scm>
     <connection>scm:git:git@github.com:aliteralmind/xbnjava.git</connection>
     <url>scm:git:git@github.com:aliteralmind/xbnjava.git</url>
     <developerConnection>scm:git:git@github.com:aliteralmind/xbnjava.git</developerConnection>
  </scm>

  <properties>
     <java.version>1.7</java.version>
     <jarprefix>R:\jeffy\programming\build\/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix>
  </properties>
  <build>
     <plugins>
        <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>build-helper-maven-plugin</artifactId>
           <version>1.8</version>
           <executions>
              <execution>
                 <id>attach-artifacts</id>
                 <phase>package</phase>
                 <goals>
                    <goal>attach-artifact</goal>
                 </goals>
                 <configuration>
                    <artifacts>
                       <artifact>
                          <file>${jarprefix}.jar</file>
                          <type>jar</type>
                       </artifact>
                    </artifacts>
                 </configuration>
              </execution>
           </executions>
        </plugin>
     </plugins>
  </build>

  <profiles>
     <!--
     This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine.
     See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven
     -->
     <profile>
        <id>release-sign-artifacts</id>
        <activation>
           <property>
              <name>release</name>
              <value>true</value>
           </property>
        </activation>
     </profile>
  </profiles>
</project>

这是一个很大的Maven问题。只剩下627个。

答案 10 :(得分:0)

我有同样的错误。我试过并重新检查了一切。我专注于Stack跟踪,我没有在Reactor摘要和堆栈跟踪之前读取构建的最后几行:

[DEBUG] Using connector AetherRepositoryConnector with priority 3.4028235E38 for http://www:8081/nexus/content/repositories/snapshots/
[INFO] Downloading: http://www:8081/nexus/content/repositories/snapshots/com/wdsuite/com.wdsuite.server.product/1.0.0-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata com.group:artifact.product:version-SNAPSHOT/maven-metadata.xml in nexus (http://www:8081/nexus/content/repositories/snapshots/)
[DEBUG] Writing tracking file /home/me/.m2/repository/com/group/project/version-SNAPSHOT/resolver-status.properties
[INFO] Uploading: http://www:8081/nexus/content/repositories/snapshots/com/...-1.0.0-20141118.124526-1.zip
[INFO] Uploading: http://www:8081/nexus/content/repositories/snapshots/com/...-1.0.0-20141118.124526-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:

这是关键:“无法找到元数据”。虽然它说它是一个身份验证错误,但它实际上已经修复了在nexus存储库中执行“重建元数据”。

希望它有所帮助。

答案 11 :(得分:0)

此外,在更新了存储库ID之后,请确保运行干净,因为release:prepare将从中断处继续。所以你可以这样做:

mvn release:prepare -Dresume=false

mvn release:clean release:prepare

答案 12 :(得分:0)

Windows中有两个setting.xml。

  • %MAVEN_HOME%\conf\
  • %userprofile%\.m2\

如果%userprofile%\.m2\setting.xml生效,maven将无法访问%MAVEN_HOME%\conf\setting.xml

答案 13 :(得分:0)

我正在处理运行的Artifactory版本5.8.4。 “设置我”功能将按如下所示生成settings.xml:

<servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"AP56eMPz8L12T5u4J6rWdqWqyhQ"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"AP56eMPz8L12T5u4J6rWdqWqyhQ"}</password>
      <id>snapshots</id>
    </server>
</servers>

使用mvn deploy -e -X开关后,我发现凭据不正确。我删除了 $ {security.getCurrentUsername()} 并将其替换为我的用户名,并删除了 $ {security.getEscapedEncryptedPassword()!“”} 并仅输入了我的加密密码对我有用:

<servers>
    <server>
      <username>username</username>
      <password>AP56eMPz8L12T5u4J6rWdqWqyhQ</password>
      <id>central</id>
    </server>
    <server>
      <username>username</username>
      <password>AP56eMPz8L12T5u4J6rWdqWqyhQ</password>
      <id>snapshots</id>
    </server>
</servers>

希望这会有所帮助!

答案 14 :(得分:0)

这可能是由于版本错误引起的,您可以仔细检查父母的版本 lib的版本,以确保它们正确无误,遇到同样的问题

答案 15 :(得分:0)

在Nexus 3.13.0-01版中,POM的id部分中的distributionManagement/repository必须与您的maven settings.xml中的servers/server/idmirrors/mirror/id相匹配。我只是用nexus v3.10.4(用3.13.0-01)代替了它,不需要匹配3.10.4。

答案 16 :(得分:0)

有类似的问题。必须将maven deploy插件固定到pom.xml中的特定版本:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
     <version>2.8.2</version>
</plugin>

此版本破坏了我的版本:

[INFO] --- maven-deploy-plugin:3.0.0-M1:deploy (default-cli) @ dbl ---

答案 17 :(得分:0)

使用files = [ "PyhtonReport_20180404_03.zip", "PyhtonReport_20180404_02.zip", "PyhtonReport_20180404_01.zip", "PyhtonReport_20181221_02.zip", "PyhtonReport_20181221_01.zip", "PyhtonReport_20180816_01.zip", ] print(distinct_dates(files)) 命令时出现401错误,原因是mvn gpg:sign-and-deploy-file不包含<MVN_HOME>/conf/settings.xml标记,而您可以通过<server>获得标记,其中{ {1}}与https://oss.sonatype.org/#profile;User%20Token

相同

要获取<id>,请运行-DrepositoryId

答案 18 :(得分:0)

就我而言,我从设置中删除了Central的服务器登录凭据。

https://github.com/scelis/twine

我不知道为什么这么做,但是由于中央Maven仓库可以匿名访问,这完全是错误的。查看导致我的错误识别和解决的调试输出。

    <server> 
        <id>central</id>
        <username>admin</username> 
        <password>******</password> 
    </server>

   <mirror>
        <id>central</id>
        <mirrorOf>central</mirrorOf>
        <name>maven-central</name>
        <url>http://www.localhost:8081/repository/maven-central/</url>
   </mirror> 

答案 19 :(得分:0)

无法传输文件:
http://mcpappxxxp.dev.chx.s.com:18080/artifactory/mcprepo-release-local/Shop/loyalty-telluride/01.16.03/loyalty-tell-01.16.03.jar
返回码是:401,ReasonPhrase:未经授权。 -> [帮助1]

解决方案:

在这种情况下,您需要更改pom文件中的版本,然后尝试使用新版本。

这里01.16.03已经存在,所以失败了,当我尝试使用01.16.04版本时,工作成功了。

答案 20 :(得分:0)

面对同样的问题。在我的情况下,原因很愚蠢-我用于授权的github令牌是为不拥有我尝试发布到的仓库的组织发行的。因此,请检查回购标题和所有权。

答案 21 :(得分:0)

如果您像我一样,从 eclipse 的 maven run 配置运行 maven compile deploy,则该问题可能与 eclipse 自己的嵌入式 maven 有关,如 https://bugs.eclipse.org/bugs/show_bug.cgi?id=562847

中所述

解决方法是从 CLI(例如 bash)运行 mvn compile deploy, 或者不要在 Eclipse 的 maven 运行配置中使用嵌入式 maven,并添加一个外部 maven(我的在 /usr/share/mvn 中),瞧,它会说 BUILD SUCCESS。

答案 22 :(得分:0)

删除 .M2 文件夹中的所有项目。然后运行 ​​mvn clean package 下载所有库。转到 eclipse 使用 maven 更新。它对我有用。

答案 23 :(得分:-1)

当尝试部署到Artifactory存储库时遇到相同的错误,以下内容为我解决了这个问题:

转到工件中的存储库设置,然后启用“ 强制Maven身份验证”和401“未经授权”错误。 (当然,您最好在settings.xml文件中以纯文本形式提供凭据,以防止出现问题

我猜默认情况下,即使通过在settings.xml文件中提供正确的凭据,它们也不会被使用,并且会出现未经授权的异常。