最近利用閑余時間,打算搭建一套基於Spring Cloud G版的微服務架構(Spring boot 2.1.0),一頓操作之后,IDEA也沒有提示什么錯誤,自認為微服務搭建完畢。啟動項目前,習慣性的Maven -clean了一下,我去,IDEA里面的Maven Projects里面一片紅,同時控制台打印出如下錯誤:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Failure to find org.springframework.cloud:spring-cloud-dependencies:pom:Greenwich.M3 in https://repo.maven.apache.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 @ line 20, column 25
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.jackpot:Logistics-management-platform:1.0-SNAPSHOT (/Users/Jackpot/Project/Logistics-management-platform/pom.xml) has 1 error
[ERROR] Non-resolvable import POM: Failure to find org.springframework.cloud:spring-cloud-dependencies:pom:Greenwich.M3 in https://repo.maven.apache.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 @ line 20, column 25 -> [Help 2]
[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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Process finished with exit code 1
錯誤提示很明顯--https://repo.maven.apache.org/maven2里面找不到Spring cloud G版的pom依賴。簡單的想了一下,之前的項目中,涉及到Spring的依賴都是https://repo.maven.apache.org/maven2里面的啊,為此我還特地打開網址看了看。

額,為什么這里面的Spring 版本只到了2.0-M4?WTF??之后的版本在哪呢?Spring Cloud G版要求Spring boot版本必須為2.1.X,而Spring boot 2.1.x對應的Spring版本那可是Spring 5啊。遇到了問題,怎么解決了,首先我想到的是去官方文檔找答案,亂搜一通,沒有找到什么有價值的內容,官方沒有明確的答案,那就只有去“民間”找方法了,第一時間想到了stackoverflow,我開發過程中的一大利器。輸入Non-resolvable import POM,立馬就出現一大堆。搜索排除后,最終鎖定了--"https://stackoverflow.com/questions/47280247/non-resolvable-import-pom-failure-to-find",一位碼友的答案完美的解決了我的問題,給我指了"明路"。
從這個回答中,很清楚的知道,Spring 2.0.0.M6版本后,依賴文件就不在https://repo.maven.apache.org/maven2里面了,而是在http://repo.spring.io/milestone/org/中,打開網址,一層層搜索,最終找到了http://repo.spring.io/milestone/org/springframework/spring/ ,Spring的所有版本都在這里,那我只需要引入這個倉庫,就可以解決問題。
在pom文件加入倉庫后,再一次Maven -clean,SUCCESS,然后Maven -compile,SUCCESS,項目也成功啟動了。