您的位置:首页 > 大数据 > 人工智能

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

2017-05-11 18:03 956 查看

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] ------------------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐