0

Maven: Non-resolvable parent POM은 같지만 같지 않습니다. 내가 부모를 구축하려고하면 module1Maven : 다른 모듈에서 가져올 수없는 POM 가져 오기

<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> 

을 가져 오려고 module3/pom.xml, 그것을 :

나는

<groupId>group</groupId> 
<artifactId>parent</artifactId> 
<version>SNAPSHOT</version> 
<packaging>pom</packaging> 

<modules> 
    <module>module1</module> 
    <module>module2</module> 
    <module>module3</module> 
</modules> 

module1 일부 dependencyManagement

자식 치어를 사용 dependencies 정의하는 부모 치어를 OK입니다

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 

하지만 아이 모듈의 빌드를 실행하면, 그것은 내가 systemPath를 사용하려고 할 것

  • 을 시도했던 있지만 import 범위를 지원하지 않습니다 무엇

    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 
    

    실패합니다.

  • 내가 부모 - 모듈에 module3에서 import 범위 dependencies 선언을 이동하려고 싶지만, 그것은

가 어떻게 혼자 서브 모듈 module3을로드/구축 할 수 있습니다 원형 의존성을 불평 실패, 또는 ​​그곳에는 멀티 서브 모듈에 dependencyManagement의 톤을 나누는 다른 방법은 없습니까?

+1

[Maven 모듈 + 단일 특정 모듈 작성] 가능한 복제본 (http://stackoverflow.com/questions/1114026/maven-modules-building-a-single-specific-module) – Tunaki

+0

@Tunaki 정보를 제공해 주셔서 감사합니다. 'mvn -pl module3 -am' 명령 줄을 사용하여 작동하지만 사실은 다른 유틸리티에서 "pam을로드하고 싶습니다."("maven-ant"를 사용하여 jetbrains IDEA에서 "running lifecycle" 로드 종속성 "에 대한 지원이 없으면 이러한 상황을 더 잘 지원할 수 없습니다. 어쩌면 나는 모든'dependencyManagements'를 부모 pom으로 옮겨야 만했다. –

답변

0

부모 수준에서 작업 할 때 Maven은 모듈 간의 종속성을 해결할 수 있습니다.

그러나 모듈 3에서 작업하는 경우 모듈 1이 프로젝트의 형제 모듈이라는 사실을 전혀 알 수 없습니다.

모듈 3 내부에서 직접 작업하려면 먼저 모듈 1을 설치해야합니다.

+0

그래서'systemPath'를 사용하려고 시도했지만 maven이 이런 유형의 임포트를 지원하지 않는다는 것을 알게되었다. –

+0

@WilliamLeung 프로젝트의 루트 레벨로 가서'mvn install' . 이후에'mvn -pl ... '을 사용하면 폴더로 바뀌지 않고 systemPath는 결코 작동하지 않을 것입니다 .... – khmarbaise