1. 程式人生 > >遇到的問題----新建maven專案ArtifactTransferException 和Execution default-testResources of goal或者匯入maven報錯

遇到的問題----新建maven專案ArtifactTransferException 和Execution default-testResources of goal或者匯入maven報錯

第一種錯誤:

ArtifactTransferException: Failure to transfer com.google.collections:google-collections:jar:1.0 from http://repo1.maven.org/maven2 was 
 cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. 
 Original error: Could not transfer artifact com.google.collections:google-collections:jar:1.0 from/to central (http://repo1.maven.org/maven2): 
 No response received after 60000




第二種錯誤:

 Execution default-testResources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:testResources failed: Unable to load 
the mojo 'testResources' in the plugin 'org.apache.maven.plugins:maven-resources-plugin:2.4.3'. A required class is missing: Lorg/sonatype/

plexus/build/incremental/BuildContext; ----------------------------------------------------- realm = plugin>org.apache.maven.plugins:maven-
resources-plugin:2.4.3 strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/D:/maven/repository/org/apache/
maven/plugins/maven-resources-plugin/2.4.3/maven-resources-plugin-2.4.3.jar urls[1] = file:/D:/maven/repository/org/apache/maven/
reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar urls[2] = file:/D:/maven/repository/org/apache/maven/doxia/doxia-sink-api/
1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar urls[3] = file:/D:/maven/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar urls[4] = file:/
D:/maven/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar urls[5] = file:/D:/maven/
repository/junit/junit/3.8.1/junit-3.8.1.jar urls[6] = file:/D:/maven/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar u


如圖:



這兩個錯誤的原因是本工程依賴的包 在本地倉庫中存在,曾經下載中超時或者未下載成功。

Maven不管下沒下成功,都會有一個.lastupdate檔案,一旦出現了這個檔案,而你指定遠端倉庫的方式是mirror,而不是profile裡的repository,那麼Maven預設不會去更新這個檔案



解決方法兩個步驟:

1.找到自己的本地倉庫,(有關本地倉庫詳見:Maven本地倉庫路徑修改),預設的路徑在本地使用者的臨時資料夾下面的 .m2 資料夾下的 repository 下,例如:C:\Users\joe\.m2\repository   repository下的資料夾全部刪除,或者只把相關報錯的包的目錄刪除


2. MyEclipse -->  Preferences -->Maven4MyEclipse ---> User Settings 

點選按鈕 Update Settings 和 點選 Reindex按鈕 

重新整理專案,應該就沒有報錯資訊了,如果還有,試試重啟MyEclipse再重新整理專案




我自己的:    看看有沒有 settings.xml  檔案。沒有的話找個別人的複製,放在上面的欄中就行了(我的這麼解決了)





自我評價:  感覺一直犯這個錯,就收藏了


原文連結: http://blog.csdn.net/zzq900503/article/details/41144803