一、情景复现
二、BUG提示
Non-resolvable parent POM for com.tt:myproject:0.0.1-SNAPSHOT: org.springframework.boot:spring-boot-starter-parent:pom:1.5.9.RELEASE failed to transfer from http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.9.RELEASE from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [alimaven (http://maven.aliyun.com/nexus/content/groups/public/, default, releases)]
三、原因分析及解决方法
(一)原因分析: maven-default-http-blocker 拦截 http 链接下载依赖。
Maven 从3.8.1开始在 setting.xml 配置文件中,增加了一个默认镜像 maven-default-http-blocker 来阻止从 HTTP 链接下载不安全的依赖库。我当前使用的 Maven 版本是 3.8.6,可以看到同样是有该拦截器的。
我配置的阿里云镜像确实是使用的 http 协议地址:
(二)解决方法
- 方法一:降级 Maven 版本到 3.8.1 以下;
- 方法二:使用 https 进行下载(推荐)。
找到 Maven 的 setting.xml 配置文件,将上述截图代码进行注释,修改阿里云镜像 url:
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>