架构师修炼之道

知识日新月异,唯有保持同步迭代,才能适应美好的未来!

0%

解决 IDEA 下载源码失败的问题maven-default-http-blocker (http://0.0.0.0/) Blocked mirror for repositories

今天发现在 IDEA 中下载源码失败,通过查看 IDEA 日志看到了出错的原因:

1
tail -f ~/Library/Logs/JetBrains/IntelliJIdea2021.3/idea.log

再次单击下载源码按钮后实时输出:

1
2
3
4
5
6
7
8
2022-01-25 17:23:15,247 [ 135367]   INFO -      #org.jetbrains.idea.maven - org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.springframework:spring-webmvc:jar:sources:5.3.15 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public, default, releases)]
in DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:424)
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework:spring-webmvc:jar:sources:5.3.15 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public, default, releases)]
in DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
... 24 more
Caused by: org.eclipse.aether.transfer.NoRepositoryConnectorException: Blocked mirror for repositories: [nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public, default, releases)]
in DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:506)
... 25 more

查到是 maven 3.8.1 版本带来的限制,详见版本说明

最后解决这个问题也比较简单,使用https协议的仓库地址即可:vim ~/.m2/settings.xml

1
2
3
4
5
6
170         <mirror>
171 <id>nexus-aliyun</id>
172 <mirrorOf>central</mirrorOf>
173 <name>Nexus aliyun</name>
174 <url>https://maven.aliyun.com/nexus/content/groups/public</url>
175 </mirror>