使用 maven 命令上传工件时出现 Nexus 存储库问题
正如您上面提到的,我已经更新了 pom
<distributionManagement>
<repository>
<id>deployment</id>
<name>deployment</name>
<url>http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8080/nexus-webapp-1.9.2/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
,并将 settings.xml
更改为类似的内容
<server>
<id>deployment</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
,但是当我使用 mvn deploy
maven 命令进行部署时,我遇到这样的异常:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Test: Failed to deploy artifacts: Could not transfer ar
tifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-
webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return code is: 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Test: F
ailed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Faile
d to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return code is: 401
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8
080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Tes
t-0.0.1.jar. Return code is: 401
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:189)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (ht
tp://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Tes
t/Test/0.0.1/Test-0.0.1.jar. Return code is: 401
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:140)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:156)
... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localho
st:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1
/Test-0.0.1.jar. **Return code is: 401**
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:267)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:334)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:136)
... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9
.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return
code is: 401
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:858)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:849)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.flush(WagonRepositoryConnector.java:773)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:385)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:241)
... 24 more
**Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1
/Test-0.0.1.jar. Return code is: 401**
at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:205)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:413)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:734)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:384)
... 25 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
Does the deployment UserID and Password not haveprivileges to upload artifact in nexus using maven deploy
? 我使用的是 Nexus 1.9.2 Nexus Professional 是否只有上传权限?请指导我。
As you have mentioned above I have updated pom like
<distributionManagement>
<repository>
<id>deployment</id>
<name>deployment</name>
<url>http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://localhost:8080/nexus-webapp-1.9.2/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
and also changed the settings.xml
to something like this
<server>
<id>deployment</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
But when I'm deploying using the mvn deploy
maven command I'm getting an exception like this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Test: Failed to deploy artifacts: Could not transfer ar
tifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-
webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return code is: 401 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Test: F
ailed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Faile
d to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return code is: 401
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8
080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Tes
t-0.0.1.jar. Return code is: 401
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:189)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (ht
tp://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Tes
t/Test/0.0.1/Test-0.0.1.jar. Return code is: 401
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:140)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:156)
... 21 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localho
st:8080/nexus-webapp-1.9.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1
/Test-0.0.1.jar. **Return code is: 401**
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:267)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:334)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:136)
... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact Test:Test:jar:0.0.1 from deployment (http://localhost:8080/nexus-webapp-1.9
.2/content/repositories/releases): Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1/Test-0.0.1.jar. Return
code is: 401
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:858)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:849)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.flush(WagonRepositoryConnector.java:773)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:385)
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:241)
... 24 more
**Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://localhost:8080/nexus-webapp-1.9.2/content/repositories/releases/Test/Test/0.0.1
/Test-0.0.1.jar. Return code is: 401**
at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:205)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:413)
at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:734)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:384)
... 25 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
Does the deployment UserID and Password not have privileges to upload artifact in nexus using maven deploy
? I'm using Nexus 1.9.2 Does Nexus Professional only have privileges to upload?. Please guide me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
另外,请确保还没有同名的工件。那里的版本 :) 如果您要部署到 Nexus 版本存储库,则无法覆盖现有文件。
Also, make sure there's not already an artifact of the same name & version there :) If you are deploying to a release Nexus repository, you cannot overwrite an existing file.
错误代码 401 表示您无权上传该文件。先检查用户并通过登录,然后检查权限。另一个问题是“部署”经常被禁用。
Error code 401 means you not authorized to upload the file. Check user and pass first by logging in, then check permissions. Another gotcha is that the "deployment" is often disabled.
您确定您的 Nexus 网址正确吗? Localhost 可能是一个糟糕的选择,通常 Nexus 使用上下文 Nexus。
Are you sure that your Nexus url is correct. Localhost is probably a bad choice and normally Nexus is using the context nexus.
如果您在计算机上本地运行Hudson,我也遇到了同样的问题,由于Windows,它在用户目录中使用他自己的文件结构的maven settings.xml。我总是修改我的maven目录中的settings.xml。当我将修改后的xml复制到hudson文件夹中时。它起作用了。您可以在这里找到 Hudson settings.xml:
如果您想检查这是否是您问题的解决方案,那么您通过 maven 进行的本地构建可以工作,但任何 Hudson 都可以作业完成失败,出现错误 401。我还尝试更改 nexus 用户设置(创建新用户,更改密码设置),因为不同的帖子建议这样做,但这不是我的情况的解决方案。
I had the same issue if your are running Hudson local on your machine, it uses maven settings.xml of his own file structure in the user directory because of windows. I always modified the settings.xml in my maven directory. When I copied the modified xml to the hudson folder. It worked.You can than find the Hudson settings.xml here:
If you want to check if this is the solution for your problem, then your local build via maven works but any Hudson job done fails with error 401. I tried also to change nexus user setting (creation of new users, change passwort settings) due different posts suggested it, but that was not the solution in my case.
您必须对密码进行加密:
You must to encrypt the password:
我通过将Maven从3.0.5版本升级到3.3.3版本解决了这个401问题。
我找到了这个链接 当 Nexus 返回时要做什么 ' 401'谈论mvn版本更新。
I resolved this 401 problem by upgrading Maven from 3.0.5 to 3.3.3 version.
I found this link What to do when Nexus returns '401' talking about mvn version update.