我想在使用maven从源代码构建它们之后,将第三方库集合部署到nexus。
我以为我能够简单地使用mvn deploy
,但我收到以下消息:
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ dcm4che-parent ---
Uploading: scp://www.dcm4che.org:443/home/maven2/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom
The authenticity of host 'www.dcm4che.org' can't be established.
RSA key fingerprint is 41:7f:10:be:8d:15:30:f1:91:59:95:c7:5d:63:f7:31.
Are you sure you want to continue connecting? (yes/no): yes
Password: :
这让我觉得它试图部署到www.dcm4che.org而不是我的nexus repo。
我不能以这种方式使用mvn deploy
吗?
我可以通过这种方式将我自己的库部署到nexus,没有任何问题。
我做错了什么?
更新
按照this answer中的建议后,我执行了以下命令:
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
我收到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to nexus (http://192.168.50.200:8081/nexus/content/repositories/thirdparty): Failed to transfer file: http://192.168.50.200:8081/nexus/content/repositories/thirdparty/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
我在settings.xml
中添加了一个条目,如下所示:
<servers>
<server>
<id>thirdparty</id>
<username>deployment</username>
<password>password</password>
<configuration></configuration>
</server>
</servers>
第二次更新
我尝试了以下命令行变体,但仍无法使其正常工作。 maven文档没有任何帮助。
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081
产生错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in thirdparty (http://192.168.50.200:8081) -> [Help 1]
和
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/
产生错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to thirdparty (http://192.168.50.200:8081/nexus/): Failed to transfer file: http://192.168.50.200:8081/nexus/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 405, ReasonPhrase: HTTP method PUT is not supported by this URL. -> [Help 1]
和
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/
产生错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in nexus (http://192.168.50.200:8081/nexus/content/repositories/) -> [Help 1]
最终更新
对于任何可能偶然发现此事的人,以下命令都有效。感谢A_Di-Matteo的帮助。
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
答案 0 :(得分:1)
您可能正在引用dcm4che-parent-3.3.7.pom
工件,其中包含:
<distributionManagement>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>scp://www.dcm4che.org:443/home/maven2</url>
</repository>
</distributionManagement>
如您所见,其distributionManagement
引用了构建错误中提到的主机,该主机用作默认主机。
如果要部署到内部Nexus,则应使用altDeploymentRepository
选项:
指定应将部署项目工件的备用存储库(除
<distributionManagement>
中指定的存储库之外)。 格式:id::layout::url
。
其用户属性为altDeploymentRepository
。
因此,您可以按如下方式调用Maven:
mvn clean deploy -DaltDeploymentRepository=yourId::layout::URL
哪个应匹配Maven settings.xml
中指定的存储库。
作为一般规则,您不应以这种方式上传到Nexus公共工件:Nexus可以为您检索它们,并用作其他远程存储库的进一步集中式缓存/治理点。
如果您要更改公共工件,然后在内部Nexus中发布它们,那么建议您更改Maven coordinates,至少添加一个classifier
来指定与您的补丁/公司相关的内容 - 名称/有用细节。