它類似於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 –