Spring Cloud项目MVN编译 -- Non-resolvable import POM

  最近利用闲余时间,打算搭建一套基于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,项目也成功启动了。

 
原文地址:https://www.cnblogs.com/JackpotHan/p/10774191.html