不能上传一个工件在Nexus仓库
问题描述:
如果我尝试使用命令上传一个jar不能上传一个工件在Nexus仓库
mvn deploy:deploy-file \
-DgroupId=log4j \
-DartifactId=log4j-gwt \
-Dversion=1.0 \
-Dpackaging=jar \
-Dfile=log4j-gwt.jar \
-DrepositoryId=nexus \
-Durl=http://2.23.45.65:8081/nexus/content/repositories/central
我得到错误
Downloaded: http://2.23.45.65:8081/nexus/content/repositories/central/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar (0 B at 0.0 KB/sec)
Uploading: http://2.23.45.65:8081/nexus/content/repositories/central/log4j/log4j-gwt/1.0/log4j-gwt-1.0.jar
Uploading: http://2.23.45.65:8081/nexus/content/repositories/central/log4j/log4j-gwt/1.0/log4j-gwt-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.964s
[INFO] Finished at: Mon Mar 21 16:45:42 MSK 2016
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project gwtclient: Failed to deploy artifacts: Could not transfer artifact log4j:log4j-gwt:jar:1.0 from/to nexus (http://2.23.45.65:8081/nexus/content/repositories/central): Failed to transfer file: http://2.23.45.65:8081/nexus/content/repositories/central/log4j/log4j-gwt/1.0/log4j-gwt-1.0.jar. Return code is: 401
描述如下仓库的Nexus如何在settings.xml
配置<mirror>
<id>nexus</id>
<url>http://2.23.45.65:8081/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
此外我试图配置组/公共存储库。 Settings.XML中
<server>
<id>nexus_public</id>
<username>username</username>
<password>passwd</password>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
在pom.xml中
<repositories>
<repository>
<id>nexus_public</id>
<url>http://2.23.45.65:8081/nexus/content/groups/public/</url>
</repository>
</repositories>
,并试图运行命令
mvn deploy:deploy-file \
-DgroupId=log4j \
-DartifactId=log4j-gwt \
-Dversion=1.0 \
-Dpackaging=jar \
-Dfile=log4j-gwt.jar \
-DrepositoryId=nexus_public \
-Durl=http://2.23.45.65:8081/nexus/content/groups/public
,但我得到同样的错误。
而且我试图找到组件上传标签,如本文 https://books.sonatype.com/nexus-book/reference/using-sect-uploading.html
中描述,但我找不到在Nexus的仓库经理OSS此选项卡。 这应该在选项卡摘要之后,但它不在那里。
答
问题是您正试图上传到存储库组。这不会奏效。您必须上传到托管存储库。
存储库组将代理和托管存储库合并为一个虚拟合并。如果您上传到作为该组的一部分的托管存储库 - 工件将在组中提供。
答
-DrepositoryId=nexus
这是错误的,您需要在包含您的登录凭据的settings.xml文件中使用服务器部分的ID。
尝试使用:
-DrepositoryId=nexus_public
而且,我不知道什么样的资源库的“中心”是您的命令,但默认情况下的Nexus附带了一个名为“*”一个代理库。您无法上传到代理或组存储库,只能上传到托管存储库。
你从哪里找到jar'log4j-gwt'?因为我没有找到它在存储库maven – Hohenheim
基于错误消息'返回代码是:401'我会假设您的凭据或您的配置,这是不好的... – khmarbaise
@Hhenhenheim我没有找到log4j-gwt也在Maven仓库中。在配置好你的网络设置(代理)之后,我已经在https://sourceforge.net/projects/log4j-gwt/ – ETartaren