它类似于Maven: Non-resolvable parent POM,但不一样。Maven:来自其他模块的不可解析的进口POM
我有一个父POM
<groupId>group</groupId>
<artifactId>parent</artifactId>
<version>SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
module1
定义了一些dependencies
使用dependencyManagement
子POM:module3/pom.xml
试图导入module1
<parent>
<artifactId>group</artifactId>
<groupId>parent</groupId>
<version>SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>module1</artifactId>
<version>SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
<!--
<systemPath>../module1</systemPath>
-->
</dependency>
</dependencies>
</dependencyManagement>
如果我尝试建立父,它是好的
mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
... ...
[INFO] parent ............................................ SUCCESS [0.128s]
[INFO] module1 ........................................... SUCCESS [0.011s]
[INFO] module2 ........................................... SUCCESS [0.009s]
[INFO] module3 ........................................... SUCCESS [0.009s]
... ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
但是,如果我的孩子模块中运行构建,它失败
mvn validate
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project group:module3:SNAPSHOT (/path-tp/project/module3/pom.xml) has 5 errors
[ERROR] Non-resolvable import POM: Failure to find group:module1:pom:SNAPSHOT in https://repo1.maven.org/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ line 22, column 19 -> [Help 2]
... ...
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
什么我已经试过
- 我会尝试使用
systemPath
但它不支持import
范围。 - 我想尝试从
module3
移动import
范围dependencies
声明父模块,但它没有抱怨圆依赖
如何建立/加载孤独的子模块module3
,或者是还有什么通过其他方式将多个子模块拆分为多个子模块dependencyManagement
?
可能重复的[Maven模块+构建单个特定模块](http://stackoverflow.com/questions/1114026/maven-modules-building-a-single-specific-module) – Tunaki
@Tunaki感谢您的信息,它使用命令行'mvn -pl module3 -am'工作,但实际上我想从其他一些实用程序(比如“jetbrains IDEA的运行生命周期”/“使用ant integration(maven-ant)”)加载子模块pom到加载依赖性“,对这些情况没有更好的支持。也许我必须将所有'dependencyManagements'移动到父pom –