使用 maven 部署项目到私服 nexus 出现 Deployment failed 问题的解决方法

3 篇文章 1 订阅

1 问题描述

一个新的工具类项目,希望部署到私服供其他项目使用。使用 maven 的 deploy 命令后,出现这个问题:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project deniro-tools: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] 

2 分析

 repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

很明显,在项目的 pom.xml 文件没有指定需要部署的私服信息!

3 解决

在 pom.xml 中新增要部署的私服信息:

<!-- 部署到 nexus 服务器-->
<distributionManagement>
    <repository>
        <id>128</id>
        <name>New Nexus Repository Releases</name>
        <url>http://xxx/nexus/content/repositories/releases/</url>
    </repository>
</distributionManagement>

在 maven 的 setting.xml 中添加服务器的账号信息,配置好后, maven 才能正常访问我们的私服,把这个项目打包上传上去:

 <server>
  <id>128</id>
  <username>xxx</username>
  <password>xxx</password>
</server>

注意:这里的 ID 必须与 pom.xml 中的 repository 的 id 一致,这样才能一一对应哦。O(∩_∩)O~

4 验证

重新运行 maven 的 deploy 命令,运行成功:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.959 s
[INFO] Finished at: 2017-05-11T17:49:28+08:00
[INFO] Final Memory: 14M/280M
[INFO] ------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值