2013-08-07 48 views
15

一位朋友向我傳遞了一個Maven項目,我試圖在我的計算機上本地運行。我在Eclipse中所做的一切,我選擇:pom.xml中存在依賴的錯誤(丟失神器...)

文件 - >導入 - >現有Maven項目

之後,該項目給我看了4個錯誤,我pom.xml(缺少神器..) :

enter image description here

我試着刪除.m2文件夾的內容,然後在Eclipse我點擊我的項目,選擇「運行方式」 - >「Maven的乾淨」,然後在「運行方式」 - >「Maven的INSTAL L」。但我仍然有同樣的錯誤。我是Spring的新手,所以我不知道還有什麼要做。

編輯:

當我嘗試這樣做:作爲運行/ Maven的安裝,這是我的控制檯說:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building DataLayer 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The POM for javax.persistence:javax.persistence:jar:1.0.0 is missing, no  dependency information available 
[WARNING] The POM for hibernate-core:hibernate-core:jar:4.2.1.Final is missing, no  dependency information available 
[WARNING] The POM for hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final is missing, no dependency information available 
[WARNING] The POM for jboss-logging:jboss-logging:jar:3.1.0.CR2 is missing, no dependency information available 
[WARNING] The POM for jta:jta:jar:1.1 is missing, no dependency information available 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.065s 
[INFO] Finished at: Wed Aug 07 11:41:45 VET 2013 
[INFO] Final Memory: 4M/90M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal on project DataLayer: Could not resolve dependencies for  project SocialManager:DataLayer:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.persistence:javax.persistence:jar:1.0.0, hibernate-core:hibernate-core:jar:4.2.1.Final, hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final, jboss-logging:jboss-logging:jar:3.1.0.CR2, jta:jta:jar:1.1: Failure to find javax.persistence:javax.persistence:jar:1.0.0 in http://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of JBoss repository has elapsed or updates are forced -> [Help 1] 
[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. 

EDIT2:這是我的完整的pom.xml:https://dl.dropboxusercontent.com/u/31349296/pom.xml它看起來很當我嘗試在這裏粘貼代碼時很糟糕。

回答

20

似乎很多依賴關係都不正確。

enter image description here

Download the whole POM here

一個很好的地方去尋找正確的依賴關係是Maven Repository網站。

+0

我是否必須在我的pom.xml的末尾添加這些行?或者它應該在其他文件中?之後,我該怎麼做?謝謝:) – kiduxa

+1

這需要輸入設置。xml – Lokesh

+0

它需要位於''標籤中,但您可以在''之前添加它。 – Bart

0

這意味着maven無法從存儲庫下載工件。 以下步驟將幫助您:

  1. 轉到存儲庫瀏覽器並檢查是否存在工件。
  2. 檢查settings.xml以查看是否指定了正確的存儲庫。
  3. 檢查代理設置。
+1

可以請你更具體嗎?那麼「轉到存儲庫瀏覽器並檢查是否存在工件」?和settings.xml位於何處?謝謝:) – kiduxa

+0

好吧,Maven從存儲庫和存儲庫下載工件,它有Web瀏覽器,但在你的情況下,這些是標準的罐子,所以這一步可以跳過。 settings.xml可以在.m2文件夾下找到。 – Lokesh

+0

.m2文件夾內有另一個名爲「repositories」的文件夾,但「repositories」文件夾中沒有settings.xml:S。 – kiduxa

0

我在失去互聯網連接後出現了這個問題。我可以通過更新Eclipse中的Maven索引來修復它,然後選擇我的項目並更新快照/發行版。

3

我知道這是一個老問題。但我希望我的回答能幫助別人。我遇到了同樣的問題,我認爲問題在於它無法在本地存儲庫中找到這些.jar文件。所以我所做的是將以下代碼添加到我的pom.xml中,並且它工作正常。

<repositories> 
    <repository> 
     <id>spring-milestones</id> 
     <name>Spring Milestones</name> 
     <url>https://repo.spring.io/libs-milestone</url> 
     <snapshots> 
      <enabled>false</enabled> 
     </snapshots> 
    </repository> 
</repositories> 
0

SIMPLE ..

首先檢查與項目的結束標記。它應該放在所有的依賴關係標籤關閉之後。這樣我就解決了我的錯誤。 --Sush 快樂編碼:)