2012-11-25 44 views
0

爲什麼.pom文件中的某些maven依賴造成如下錯誤:Missing artifact nonfree-lingpipe:lingpipe:jar:2.3.1?所有依賴項都列在.pom文件中。在.m2文件夾中,我有所有的依賴文件夾,但不是所有的罐子:所以對於nonfree-lingpipe:lingpipe:jar:2.3.1 - 沒有罐子,但我有一個用於4.1.0。爲什麼maven沒有那個,但搜索2.3.1?我沒有看到.pom文件中的任何版本,只有名稱。爲什麼maven導致依賴性錯誤?

回答

0

Maven依賴關係必須指定一個版本號。如果你不能看到那麼一個列出您必須在POM中有dependency management元素或它的某個父:

<project> 
    ... 
    <dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>nonfree-lingpipe</groupId> 
     <artifactId>lingpipe:jar</artifactId> 
     <version>2.3.1</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 
    ... 
</project> 

要進行更改到4.1.0,您必須在您的依賴顯式地指定版本聲明或尋找依賴管理部分並在那裏進行更改。

0

dependencyManagement中的定義僅定義了應該使用verison的工件,但並未真正使用此工件。此外給出的例子:

<dependencies> 
    <dependency> 
    <groupId>nonfree-lingpipe</groupId> 
    <artifactId>lingpipe:jar</artifactId> 
    <version>2.3.1</version> 
    </dependency> 
</dependencies> 

是錯誤的,導致artifactId不應該包含冒號。正確的方法是:

<dependencies> 
    <dependency> 
    <groupId>nonfree-lingpipe</groupId> 
    <artifactId>lingpipe</artifactId> 
    <version>2.3.1</version> 
    </dependency> 
</dependencies> 

此外,您需要在dependencyManagement塊之外定義此依賴關係以真正使用此依賴關係。