如何将第三方库集部署到 Nexus
How to deploy a 3rd party set of libs to Nexus
我想在使用 maven 从源代码构建库后将第 3 方库集部署到 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 存储库。
这样可以不使用mvn deploy
吗?
我可以通过这种方式将我自己的库部署到 nexus,没有任何问题。
我做错了什么?
更新
遵循 中的建议后,我执行了以下命令:
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
您可能指的是 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
选项:
Specifies an alternative repository to which the project artifacts should be deployed (other than those specified in <distributionManagement>
).
Format: id::layout::url
.
它的用户属性是altDeploymentRepository
。
因此,您可以按如下方式调用 Maven:
mvn clean deploy -DaltDeploymentRepository=yourId::layout::URL
这应该与您的 Maven settings.xml
中指定的存储库匹配。
作为一般规则,您不应以这种方式上传到 Nexus public 工件:Nexus 可以为您检索它们并用作其他远程存储库的进一步集中 cache/governance 点。
如果您要更改 public 工件,然后将它们发布到您的内部 Nexus 中,那么建议您更改它们的 Maven coordinates,至少添加一个 classifier
指定相关的内容到你的 patch/company-name/useful-detail.
我想在使用 maven 从源代码构建库后将第 3 方库集部署到 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 存储库。
这样可以不使用mvn deploy
吗?
我可以通过这种方式将我自己的库部署到 nexus,没有任何问题。
我做错了什么?
更新
遵循
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
您可能指的是 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
选项:
Specifies an alternative repository to which the project artifacts should be deployed (other than those specified in
<distributionManagement>
). Format:id::layout::url
.
它的用户属性是altDeploymentRepository
。
因此,您可以按如下方式调用 Maven:
mvn clean deploy -DaltDeploymentRepository=yourId::layout::URL
这应该与您的 Maven settings.xml
中指定的存储库匹配。
作为一般规则,您不应以这种方式上传到 Nexus public 工件:Nexus 可以为您检索它们并用作其他远程存储库的进一步集中 cache/governance 点。
如果您要更改 public 工件,然后将它们发布到您的内部 Nexus 中,那么建议您更改它们的 Maven coordinates,至少添加一个 classifier
指定相关的内容到你的 patch/company-name/useful-detail.