maven版本:3.2.2
eclipse已經(jīng)正確引入自己安裝的maven,且設置好倉庫位置
引入maven工程時,pom.xml出現(xiàn)錯誤如:
一般都是導入別人的工程,因為自己的maven環(huán)境、倉庫配置信息、下載的jar包來源、甚至時IDE環(huán)境不一致導致
1.檢查maven本地倉庫中是否存在改包
(1)若存在:刪掉_maven.repositories和_remote.repositories文件(或用文本編輯器打開,將“>main=”改為“>=”,即刪除main,當然main也可能是其他值),刪除xxxx.lastUpdate相關文件,然后update project 或 update dependency
(2)不存在看第2條
2.settings.xml文件是否配置了mirror,即maven下載jar的倉庫;是否聯(lián)網(wǎng);若都沒問題看第3條
3.去settings.xml文件配置的mirror倉庫地址查看對應的jar是否存在這個倉庫。若找不到,那就換mirror吧,推薦國內(nèi)網(wǎng)速較快的鏡像地址:
- <mirror>
- <id>alimaven</id>
- <name>aliyun maven</name>
- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
- <mirrorOf>central</mirrorOf>
- </mirror>
放到<mirrors>標簽中即可
或者其它mirror地址如:開源中國的等等
4.直接去maven中央倉庫手動對應版本的jar,放到本地倉庫對應位置,刪除文件夾內(nèi)不相關文件,重新項目右鍵-->maven -->update 依賴或者update project
找到了我的倉庫對應的jar位置,發(fā)現(xiàn)存在改jar,刪除對應的jar:
eclipse中對項目:右鍵-->maven--->update project
問題解決!
_maven.repositories簡介:
_maven.repositories hold the information about the origin of the artefacts. Maven tries to update your jar from the old location (as saved in _maven.repositories) and fails. The presumtion here is that the same aftifact on a different remote repository might be different.
以上為個人嘗試過的解決方案,若有其它解決方案,或者出錯說明,歡迎留言,不勝感激!