我在使用Maven的SNAPSHOT构建中的构建顺序有问题。Reactor正在以无效的顺序构建所有罐子。
下面是一个重新创建问题的示例结构(我遇到问题的项目要大得多,
pom.xml [reactor]
parent/pom.xml [parent]
jar1/pom.xml
jar2/pom.xml
jar3/pom.xml
波姆。xml[Reactor]
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<groupId>com.test.buildorder</groupId>
<artifactId>reactor</artifactId>
<version>1.0</version>
<modules>
<module>jar3</module>
<module>jar2</module>
<module>jar1</module>
</modules>
</project>
家长/家长。xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.buildorder</groupId>
<artifactId>parent</artifactId>
<version>1.1</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.test.buildorder</groupId>
<artifactId>jar1</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.test.buildorder</groupId>
<artifactId>jar2</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.test.buildorder</groupId>
<artifactId>jar3</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
JAR1/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.buildorder</groupId>
<artifactId>jar1</artifactId>
<version>1.1</version>
<parent>
<groupId>com.test.buildorder</groupId>
<artifactId>parent</artifactId>
<version>1.1</version>
</parent>
</project>
JAR2/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.buildorder</groupId>
<artifactId>jar2</artifactId>
<version>1.1</version>
<parent>
<groupId>com.test.buildorder</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>com.test.buildorder</groupId>
<artifactId>jar1</artifactId>
</dependency>
</dependencies>
</project>
JAR3/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.buildorder</groupId>
<artifactId>jar3</artifactId>
<version>1.1</version>
<parent>
<groupId>com.test.buildorder</groupId>
<artifactId>parent</artifactId>
<version>1.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.test.buildorder</groupId>
<artifactId>jar2</artifactId>
</dependency>
</dependencies>
</project>
我的存储库(在本例中是本地的)只有每个jar的1.0版本,jar3-1.0依赖于jar2-1.0,jar2-1.0依赖于jar1-1.0,每个jar2-1.0都有parent-1.0(如果需要,我可以发布这段代码,但我的问题已经很长了,所以除非有人问我,否则我会推迟)。
我现在安装上面的1.1父pom,然后尝试在反应器上运行安装,并得到以下结果。
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.test.buildorder:jar3:jar:1.1
[WARNING] 'parent.relativePath' points at com.test.buildorder:reactor instead of com.test.buildorder:parent, please verify your project structure @ line 6, column 11
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.test.buildorder:jar2:jar:1.1
[WARNING] 'parent.relativePath' points at com.test.buildorder:reactor instead of com.test.buildorder:parent, please verify your project structure @ line 6, column 11
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.test.buildorder:jar1:jar:1.1
[WARNING] 'parent.relativePath' points at com.test.buildorder:reactor instead of com.test.buildorder:parent, please verify your project structure @ line 6, column 11
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] jar3
[INFO] jar2
[INFO] jar1
[INFO] reactor
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jar3 1.1
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/com/test/buildorder/jar1/1.1/jar1-1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] jar3 ............................................... FAILURE [ 0.645 s]
[INFO] jar2 ............................................... SKIPPED
[INFO] jar1 ............................................... SKIPPED
[INFO] reactor ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.775 s
[INFO] Finished at: 2015-06-03T16:56:04-05:00
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project jar3: Could not resolve dependencies for project com.test.buildorder:jar3:jar:1.1: Could not find artifact com.test.buildorder:jar1:jar:1.1 in central (https://repo.maven.apache.org/maven2) -> [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/DependencyResolutionException
当我构建1.0版本时,Reactor足够聪明,可以实现依赖树jar3-1.0-
现在,由于jar3-1.1依赖于jar2-1.0(在repo中),反应器并不认为需要首先构建jar1,但调试(使用-X参数)显示依赖关系树为:
[DEBUG] com.test.buildorder:jar3:jar:1.1
[DEBUG] com.test.buildorder:jar2:jar:1.0:compile
[DEBUG] com.test.buildorder:jar1:jar:1.1:compile (version managed from 1.0 by com.test.buildorder:parent:1.1)
所以我对这个场景有几个问题:
1。为什么maven认为jar3-1.1对jar1-1.1有一个可传递的依赖关系
2。为什么Reactor没有意识到这种可传递的依赖性,并按照要求的顺序进行构建以满足它
3。我能做些什么来防止这个问题的发生?(最好不重写超过100个POM。)
编辑:找到了第一个问题的答案和第三个问题的一个解决方案。但是仍然想听听第二个问题。
1.因为我从来没有定义依赖项的作用域,maven确定分配了compile
的默认作用域。因此,从jar2到jar1的依赖项将显示为依赖于jar2(例如jar3)的jar的传递依赖项。(由com.test.buildorder管理的版本从1.0:父:1.1)
通知我依赖项是从jar2-1.0到jar1-1.0,但是因为父为jar 1(1.1)指定了另一个版本,所以需要它。
3.如果我将依赖关系的范围从jar2更改为jar1,并将其更改为provided
,则依赖关系不再是可传递的。这假设在运行时所需的JAR都会出现,所以这可能不是每个遇到这个问题的人的解决方案。以下是Maven中可用范围的指南
关于问题2:MavenReactor排序不适用于可传递依赖项,它只计算直接依赖项:
>
jar3-1.1依赖于jar2-1.0(不在反应器中)
jar2-1.1依赖于jar1-1.1
JAR1-1.1
在这种情况下,jar3-1.1和jar1-1.1之间没有链接
预计您不会将反应器中的jar2-1.1与从属管理中的jar2-1.0混合使用
[警告]在为com.test.buildorder构建有效模型时遇到了一些问题: jar3: jar: 1.1[警告]'parent.relative路径'点com.test.buildorder:Reactor而不是com.test.buildorder:父,
因为你的反应器不是父对象,所以我假设你需要明确定义相对路径
<parent>
<groupId>com.test.buildorder</groupId>
<artifactId>parent</artifactId>
<version>1.1</version>
<relativePath>../parent</relativePath>
</parent>
此外,您还有不同版本的jar2
1.0
和1.1
。对齐它们
我在这里安装了所有项目,所有版本都设置为1.0
。然后我改变了你说的版本,得到了同样的错误。
将反应器
POM更改为:
<modules>
<module>jar1</module>
<module>jar2</module>
<module>jar3</module>
</modules>
... 建造成功了。
我看了《使用多个模块、Reactor分拣的指南》,最后一个选项是:
中声明的顺序
读完下一句:
请注意,仅使用“实例化”引用-
dependencyManagement
和pluginManagement
元素不会导致反应器排序顺序的更改
我修复了Reactor
POM
- 我对
建造成功了:
[INFO] Reactor Build Order
[INFO]
[INFO] jar3
[INFO] jar1
[INFO] jar2
[INFO] reactor
java.lang.noClassDefoundError:scala/collection/gentraversableonce$class at kafka.utils.pool.(pool.scala:28)~[kafka2.10-0.8.1.1.jar:na] at kafka.consumer.FetchRequestandResponseStatsRegistry$.~[kafka2.
在SecurityServiceImpl中注入此RoleRepo时,我面临此错误。 我的spring上下文文件 我的角色类
我看了所有类似的问题,没有一个能帮助我,所以事情是这样的: 为了在不同的程序中重现错误,我创建了一个简单的Spring Boot程序。在尝试运行它时,我遇到了一个我无法解决的非常奇怪的错误: 相关类别: 通用域名格式。实例演示。演示应用程序。爪哇: com.example.demo.configs.RootConfiguration.java 通用域名格式。实例演示。控制器。测试控制器。爪哇: 我
我从Spring MVC开始,阅读了《Spring in Action》一书,我正在使用Spitter应用程序进行第5章的练习,但我遇到了以下错误: org.springframework.beans.factory.[C:\xampp\htdocs.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\spitter\WEB-I
我正在尝试使用cucumber框架与selenium和appium,但在执行cucumber特性时,我得到以下异常: @CucumberOptions(features={“src//test//java//feature”},glue={“pages”},plugin={“pretty”,“html:target/cucumber”},tags={“@web”,“@test”,“@appium”
堆栈跟踪