问题描述
为什么我在Maven中收到401 Unauthorized错误?
这是我在调用 mvn deploy时遇到的错误
(底部的完整日志):
[INFO] BUILD FAILURE
[错误]无法在项目xbnjava上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy):无法部署工件:无法传输artifact com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-staging(https://oss.sonatype.org/service/local/staging/deploy/maven2/):无法传输文件: https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。 - > [帮助1]
根据此,settings.xml必须位于以下两个位置之一:
- Maven安装:
$ M2_HOME / conf / settings.xml
- 用户的安装:
$ {user.home} /.m2 / settings.xml
这是我的设置:
-
settings.xml
:C:\ applications \ programming\apache-maven-3.2.2\conf\settings.xml
-
M2_HOME
是C:\applications \programming\apache-maven-3.2.2
输出 mvn help:effective-settings
:
[C:\applications\utilities\curl]
[INFO]扫描项目...
[INFO]
[INFO] ---------- ---------------------------- ----------------------------------
[INFO]建立Maven Stub项目(无POM)1
[INFO] ------------------------------------------- -----------------------------
[INFO]
[INFO] --- maven-help-插件:2.2:有效设置(default-cli)@ standalone-pom ---
[INFO]
有效的用户特定配置设置:
<?xml version =1.0encoding =UTF-8?>
<! - ========================================= ============================= - >
<! - - >
<! - 由Maven帮助插件生成于2014-07-18T12:48:19 - >
<! - 请参阅:http://maven.apache.org/plugins/maven-help-plugin/ - >
<! - - >
<! - ========================================= ============================= - >
<! - ===================================== ================================= - >
<! - - >
<! - 'kermit-the-frog'上'jeffy'的有效设置 - >
<! - - >
<! - ========================================= ============================= - >
< settings xmlns =http://maven.apache.org/POM/4.0.0xmlns: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]建立成功
[INFO] - -------------------------------------------------- ---------------------
[INFO]总时间:2.310 s
[INFO]完成时间:2014-07-18T12:48 :19-04:00
[INFO]最终记忆:7M / 17M
[INFO] ------------------------ ------------------------------------------------
我不明白它指的是哪个网址。
I我正在使用最新版本:
[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版本:1.7.0_51,供应商:Oracle公司
Java主页:C:\applications \programming \ jdk_7_51 \ jre
默认语言环境:en_US,平台编码:Cp1252
操作系统名称:windows 7,版本:6.1,arch:x86,系列:windows
---- --------------
完整 settings.xml
和 pom.xml
files
( mvn deploy
的完整日志和 mvn deploy -e
下面)
settings.xml
:
<?xml version =1.0encoding =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>
pom.xml:
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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是一组通用的后端(服务器端,非GUI)编程实用程序,具有RegexReplacer和FilteredLineIterator。 XBN-Java是Codelet的基础(http://codelet.aliteralmind.com)。< / description>
< parent>
< groupId> org.sonatype.oss< / groupId>
< artifactId> oss-parent< / artifactId>
< version> 7< / version>
< / parent>
< licenses>
< license>
< name>较小的通用公共许可证(LGPL)版本3.0< / name>
< url> https://www.gnu.org/licenses/lgpl-3.0.txt< / url>
< / license>
< license>
< name> Apache软件许可证(ASL)版本2.0< / name>
< url> http://www.apache.org/licenses/LICENSE-2.0.txt< / url>
< / license>
< / licenses>
< developers>
< developer>
< name> Jeff Epstein< / name>
< email> [email protected]< / email>
< roles>
< role>首席开发人员< / role>
< / roles>
< / developer>
< / developers>
< issueManagement>
< system> GitHub问题跟踪器< / 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:[email protected]:aliteralmind / xbnjava.git< / connection>
< url> scm:git:[email protected]:aliteralmind / xbnjava.git< / url>
< developerConnection> scm:git:[email protected]: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>工具< / 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>
<! -
此配置文件将使用本地计算机上的GPG密钥对JAR文件,源文件和javadocs文件进行签名。
请参阅: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]扫描项目...
[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]安装R:\ jeffy \programming\sandbox\z__for_git_commit_only\\ xbnjava\pom.xml到C:\ Users \ jeffy \.m2 \repository \ com \ gesub \aliteralmind \ xbnjava \0.1.2 \ xbnjava-0.1.2.pom
[INFO]安装R: \ jeffy \programming\build\xbnjava-0.1.2 \download \xbnjava-0.1.2-all.jar to C:\ Users \ jeffy \.m2 \ store \ com \\ github \aliteralmind \ xbnjava \0.1.2 \ xbnjava-0.1.2.jar
[INFO] --- maven-deploy-plugin:2.7:deploy(default-deploy)@ xbnjava - -
上传: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]总时间:3.204 s
[INFO]完成时间:2014-07-18T11:25:17-04:00
[INFO]最终记忆:7M / 17M
[INFO] ---- -------------------------------------------------- ------------------
[错误]无法执行目标org.ap. ache.maven.plugins:maven-deploy-plugin:2.7:在项目xbnjava上部署(默认部署):无法部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype -nexus-staging(https://oss.sonatype.org/service/local/staging/deploy/maven2/):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/ maven2的/ COM / github上/ aliteralmind / xbnjava / 0.1.2 / xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。 - > [帮助1]
[错误]
[错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。
[错误]使用-X开关重新运行Maven以启用完整的调试日志记录。
[错误]
[错误]有关错误和可能解决方案的更多信息,请阅读以下文章:
[错误] [帮助1] http://cwiki.apache.org / confluence / display / MAVEN / MojoExecutionException
mvn deploy -e
输出:
[INFO]错误堆栈跟踪已打开。
[INFO]扫描项目...
[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]安装R:\ jeffy \programming\sandbox\z__for_git_commit_only\\ xbnjava\pom.xml到C:\ Users \ jeffy \.m2 \repository \ com \ gesub \aliteralmind \ xbnjava \0.1.2 \ xbnjava-0.1.2.pom
[INFO]将R:\ jeffy \programming\build\xbnjava-0.1.2 \download \ xbnjava-0.1.2-all.jar安装到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 ---
上传: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]总时间:3.492 s
[INFO]完成时间:2014年-07-18T11:25:37-04:00
[INFO]最终记忆:7M / 17M
[INFO] ------------------ -------------------------------------------------- ----
[错误]无法在项目xbnjava上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy):无法部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/ github上/ aliteralmind / xbnjava / 0.1.2 / xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。 - > [帮助1]
org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目xbnjava上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy):失败部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-staging(https://oss.sonatype.org/service/local/staging/deploy/maven2/) :无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder。 java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org .apache.maven.cli.MavenCli.doMain(MavenC li.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method。 java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher。 java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher。 java:356)
引起:org.apache.maven.plugin.MojoExecutionException:无法部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-登台(https://oss.sonatype.org/service/local/staging/ deploy / maven2 /):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom 。返回码为:401,ReasonPhrase:未经授权。
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19更多
引起:org.apache.maven.artifact.deployer.ArtifactDeploymentException :无法部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-staging(https://oss.sonatype.org/service/local/staging/deploy/ maven2 /):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:149)
... 21 more
引起:org.eclipse.aether.deployment.DeploymentException :无法部署工件:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-staging(https://oss.sonatype.org/service/local/staging/deploy/ maven2 /):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:337)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:268)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 23更多
引起:org.eclipse.aether.transfer.ArtifactTransferException:无法传输工件com.github.aliteralmind:xbnjava:pom:0.1.2 from / to sonatype-nexus-暂存(https://oss.sonatype.org/service/local/staging/deploy/maven2/):无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com /github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector $ 6.wrap(WagonRepositoryConnector.java:1016)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector $ 6.wrap(WagonRepositoryConnector.java: 1004)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector $ PutTask.run(WagonRepositoryConnector.java:895)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector。 java:522)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:331)
... 26 more
引起:org.apache.maven .wagon.TransferFailedException:无法传输文件:https://oss.sonatype.org/service/local/staging/deploy/maven2/com/github/aliteralmind/xbnjava/0.1.2/xbnjava-0.1.2.pom。返回码为:401,ReasonPhrase:未经授权。
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon。 java:493)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon。 put(AbstractHttpClientWagon.java:454)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector $ PutTask.run(WagonRepositoryConnector.java:871)
... 28 more
[ERROR ]
[错误]使用-X开关重新运行Maven以启用完整的调试日志记录。
[错误]
[错误]有关错误和可能解决方案的更多信息,请阅读以下文章:
[错误] [帮助1] http://cwiki.apache.org / confluence / display / MAVEN / MojoExecutionException
我是尝试将Gradle人工制品部署到Nexus Sonatype存储库时出现类似错误。如果您提供了错误的凭据(密码等),您将收到401 Unauthorized错误。如果您尝试将某些内容发布到版本库并且该版本已存在于存储库中,那么您也会收到错误(并且我的头脑也是401)。因此您可能会发现从命令行发布它可以工作,但是当你从脚本中执行它时它会失败(因为它第一次出现在存储库中时不存在)。使用不同的版本号发布,或删除服务器上的旧工件并重新发布。
SNAPSHOTS存储库(与发布存储库相对)允许您覆盖类似编号的版本,但您的版本号应该在其末尾有-SNAPSHOT。
Why am I getting a "401 Unauthorized" error in Maven?
Here's the error I'm getting when calling mvn deploy
(full logs at the bottom):
[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]
According to this sonatype support page:
Below are the steps I've taken, below that are my full settings.xml
and pom.xml
files, and below that are the full logs from mvn deploy
and mvn deploy -e
.
Any ideas would be appreciated. I am just hitting wall after wall with Maven.
I followed sonatype's checklist when receiving a 401 error:
- I successfully logged in and out of the sonatype.org website, using the user/pass in
settings.xml
. - I attempted to use
curl
to manually deploy an artifact, with the command
[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
but got this error:
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.
I ran it again with the -k
option, and this time got only this:
Couldn't read data from file "pom.xml", this makes an empty POST.
I've never used curl before, so I'm at a loss on what to do with this information.
I don't know what "drop" means. I believe my privileges are properly installed, as I received this message from sonatype:
- Configuration has been prepared, now you can:
- Deploy snapshot artifacts into repository https://oss.sonatype.org/content/repositories/snapshots
- Deploy release artifacts into the staging repository https://oss.sonatype.org/service/local/staging/deploy/maven2
- Promote staged artifacts into repository 'Releases'
- Download snapshot and release artifacts from group https://oss.sonatype.org/content/groups/public
- Download snapshot, release and staged artifacts from staging group https://oss.sonatype.org/content/groups/staging
and I have successfully put these items onto the server via mvn deploy
in the past couple days.
The project's settings:
- In
settings.xml
, settings/servers/server/id equalsossrh
- In
pom.xml
, distributionManagement/snapshotRepository/id equalsossrh
(full files are at the bottom)
According to Maven's settings reference, settings.xml must be in one of two locations:
- The Maven install:
$M2_HOME/conf/settings.xml
- A user’s install:
${user.home}/.m2/settings.xml
Here's my setup:
settings.xml
:C:\applications\programming\apache-maven-3.2.2\conf\settings.xml
M2_HOME
isC:\applications\programming\apache-maven-3.2.2
Output for mvn help:effective-settings
:
[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] ------------------------------------------------------------------------
I don't understand which url it's referring to.
I am using the latest version:
[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"
------------------
Full settings.xml
and pom.xml
files
(Full logs for mvn deploy
and mvn deploy -e
below)
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>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>
pom.xml:
<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>[email protected]</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:[email protected]:aliteralmind/xbnjava.git</connection>
<url>scm:git:[email protected]:aliteralmind/xbnjava.git</url>
<developerConnection>scm:git:[email protected]: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>
------------------
Full logs for mvn deploy
and mvn deploy -e
mvn deploy
output:
[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
(Failure section:)
[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
output:
[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
(Failure section:)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.492 s
[INFO] Finished at: 2014-07-18T11:25:37-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]
org.apache.maven.lifecycle.LifecycleExecutionException: 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.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: 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.
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: 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.
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:149)
... 21 more
Caused by: org.eclipse.aether.deployment.DeploymentException: 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.
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:337)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:268)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 23 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: 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.
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:895)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:522)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:331)
... 26 more
Caused by: org.apache.maven.wagon.TransferFailedException: 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.
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:493)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474)
at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:454)
at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
... 28 more
[ERROR]
[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
I've had similar errors when trying to deploy a Gradle artefact to a Nexus Sonatype repository. You will get a 401 Unauthorized error if you supply the wrong credentials (password etc). You also get an error (and off the top of my head is also a 401) if you try to publish something to a releases repository and that version already exists in the repository. So you might find that by publishing from the command line it works, but then when you do it from a script it fails (because it didn't exist in the repository the first time around). Either publish using a different version number, or delete the old artefact on the server and republish.
The SNAPSHOTS repository (as opposed to the releases repository) allows you to overwrite a similarly numbered version, but your version number should have "-SNAPSHOT" at the end of it.
这篇关于为什么我会收到“401 Unauthorized” Maven中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!