2014-09-22 165 views
1

我在管理繼承的依賴關係時遇到問題。我有,在水平之上,我的「頂」級項目,擁有自己的pom.xml具有如何從父對象繼承父對象到另一個父對象?

<dependencyManagement> 
     <dependencies> 
      <!-- Utils --> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
       <version>4.11</version> 
      </dependency> 
     </dependencies> 
</dependencyManagement> 

在另一邊,我有我的「第二級」項目,該項目繼承了頂級項目並且我想繼承junit依賴關係:

<parent> 
     <artifactId>com.test</artifactId> 
     <groupId>top-level-class</groupId> 
     <version>0.0.1-SNAPSHOT</version> 
    </parent> 

<dependencyManagement> 
     <dependencies> 
      <!-- Utils --> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </dependency> 
     </dependencies> 
</dependencyManagement> 

但是,這是捕獲依賴項的版本。它說:「管理版本無法確定,工件管理在com.test.second-level-test:0.0.1-SNAPSHOT」

有沒有人有任何關於如何解決這個問題的想法?問候

+1

只是刪除它從孩子的POM的... – StackFlowed 2014-09-22 13:18:58

+0

你有沒有宣佈「第二級」項目爲父母的模塊? – geoand 2014-09-22 13:19:02

+0

我把它作爲,因爲我想要這些依賴項繼承到另一個太陽項目。 – jscherman 2014-09-22 13:20:39

回答

4

你的第二級POM應該像這樣(的依賴應該是直屬項目):

 <project blabla> 
    <parent> 
     <artifactId>com.test</artifactId> 
     <groupId>top-level-class</groupId> 
     <version>0.0.1-SNAPSHOT</version> 
    </parent> 

    .... 

     <dependencies> 
      <!-- Utils --> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </dependency> 
     </dependencies> 
    ... 

    </project> 
+0

但通過這種方式,這個項目的太陽不會繼承junit的依賴,是嗎? – jscherman 2014-09-22 15:05:33

相關問題