Maven 如何将第三方LIB集部署到Nexus

Maven 如何将第三方LIB集部署到Nexus,maven,nexus,dcm4che,maven-deploy-plugin,Maven,Nexus,Dcm4che,Maven Deploy Plugin,在使用maven从源代码构建库之后,我想将第三方库集部署到nexus 我以为我可以简单地使用mvn部署,但我得到了以下信息: [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

在使用maven从源代码构建库之后,我想将第三方库集部署到nexus

我以为我可以简单地使用
mvn部署
,但我得到了以下信息:

[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

我可以通过这种方式将自己的libs部署到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>
产生错误:

[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]
[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]
[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]

产生错误:

[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]
[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]
[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]

产生错误:

[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]
[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]
[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]
最终更新

对于任何可能偶然发现这一点的人来说,下面的命令是有效的。多亏了阿努迪马特奥的帮助

mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty

您可能指的是工件,其中:

<distributionManagement>
    <repository>
      <id>www.dcm4che.org</id>
      <name>dcm4che Repository</name>
      <url>scp://www.dcm4che.org:443/home/maven2</url>
    </repository>
</distributionManagement>
它应该与Maven
settings.xml
中指定的存储库相匹配


一般来说,您不应该以这种方式上传到Nexus公共工件:Nexus可以为您检索它们,并用作其他远程存储库的进一步集中化缓存/治理点


如果您正在更改公共工件,然后在您的内部Nexus中发布它们,那么建议您更改它们的,至少添加一个
分类器
指定与您的补丁程序/公司名称/有用细节相关的内容。

首先,我怀疑使用
scp
作为协议是一个好主意,Nexus也不经常使用它。使用(http/https)。此外,您需要在pom.xml中的某个地方更改distributionManagement…我不知道
scp
在部署中的位置或方式。这不是我故意指定的任何内容。@ksl您的设置代码段中的id是
thirdparty
,而您在命令行中传递了
nexus
,这是一个mismatch@ksl从第二次更新开始,您正确地使用了该选项,但您传递的url不正确。您应该传递一个有效的存储库URL,如
http://localhost:8081/nexus/content/repositories/releases
其中
releases
是Nexus上配置的存储库。因此,在这种情况下,部署
deploy
插件没有问题。那么,我应该将dcm4che repo添加到我的nexus配置中吗?当我构建依赖于dcm4che的应用程序时,maven将从中提取它需要的东西,然后构建它?@ksl是的,这是推荐的方法,不需要上传您需要的每个外部依赖项。Nexus将为您提取它们并存储在其缓存中。