有些像Maven: Non-resolvable parent 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
儿童游戏: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
但是如果我在子模块中运行build,它就会失败
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
范围不支持。import
范围dependencies
声明从module3
移到父模块,但它没有抱怨循环依赖如何构建/加载单独的子模块module3
,还是有其他方法可以将大量的dependencyManagement
拆分为多个子模块?
答案 0 :(得分:0)
在父级别工作时,Maven能够解决模块之间的依赖关系。
但是如果你在模块3中工作,它不知道module1是项目的兄弟模块。
如果您想直接在模块3内部工作,则需要先安装模块1。