今天下午遇到个使用maven的deploy插件推送内网仓库依赖包问题,如下:
英文不好的看见full stack ,第一眼以为是栈满了,仔细看,关键报错是这句:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xxx: 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] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
查了查相关文档(就是不停百度。。。)
给出结论为:
deploy2.7版本和2.8版本有差异,我们在用2.7版本是,项目中指定了内网仓库路径,可能会和setting.xml发生冲突(其实推送时会报错,但是测试过程中发现,其他项目已经能引入最新包的代码,这种属实是偶然现象,我也没找到具体原因,先说解决办法吧。)
2.8 版本会使用 setting.xml 中的配置
解决办法:
注释掉项目中引入内网仓库地址,修改deploy插件版本号为2.8
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
测试结果: