我们使用maven 2.2.1构建项目。主pom列出了构建的模块(一些WAR项目和一些“普通”JAR)。
最近,我们在一个战争项目中增加了一个新的依赖项:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.6</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
<exclusion>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
</exclusion>
</exclusions>
</dependency>当在开发人员机器上从命令行(mvn干净包)本地构建时,它工作得很好。但是,当构建在自动构建系统(由Hudson构建)上时,httpcore JAR (它是httpclient的依赖项)没有打包到最终的WAR中。没有报告错误,只是缺少了JAR。
maven settings.xml文件是相同的(除了回购路径-唯一值得注意的非默认选项是offline=true)。有什么不对的?
发布于 2015-10-15 20:47:59
我想到的唯一一件事是,您的构建机器在m2回购中有一个模块的旧版本。清除整个$HOME/.m2/repository (或您保存回购的位置),然后再试一次。
发布于 2015-10-15 21:46:00
发现问题了。(并已解决)
简而言之:回购中的httpclient.jar没有它的.pom文件。(所以maven不知道它有依赖关系)
长:
它是一个离线存储库,因此丢失的工件必须手动修复。问题是,我首先将文件复制到错误的文件夹,而maven没有“看到”它们。然后“盲目地”听从了它的建议:
Missing:
----------
1) org.apache.httpcomponents:httpclient:jar:4.2.6
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.apache.httpcomponents -DartifactId=
httpclient -Dversion=4.2.6 -Dpackaging=jar -Dfile=/path/to/file这只会将jar文件复制到回购程序中,而不需要pom。
因此,我只是将httpclient的完整文件夹复制到repo中(以及它的父文件和maven随后抱怨的其他相关文件)。
我想这是用户错误的一种形式。
https://stackoverflow.com/questions/33157902
复制相似问题