1

我想在使用 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
4

1 回答 1

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 坐标,至少添加一个classifier与您的补丁/公司名称/有用细节相关的指定内容。

于 2016-06-23T14:59:32.087 回答