文章目录
- 一、前言
- 二、遇到问题
- 三、分析问题
- 四、使用国内镜像
- 五、重新编译验证
一、前言
遇到这个问题,有两种解决办法
- IDEA Maven使用HTTP代理,解决Could not transfer artifact org.xxx问题
- IDEA Maven使用国内镜像,解决Could not transfer artifact org.xxx问题
二、遇到问题
- 使用IDEA运行一个Java Demo时,遇到一个问题:
Could not transfer artifact org.xxx
Connection refused: connect
org.springframework.boot:spring-boot-starter-parent:pom:3.3.2 failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:3.3.2 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/3.3.2/spring-boot-starter-parent-3.3.2.pom
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:3.3.2 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/3.3.2/spring-boot-starter-parent-3.3.2.pom
三、分析问题
- 根本原因就是
https://repo.maven.apache.org/maven2
网址无法访问 - 前一篇博文是通过HTTP代理解决,但是如果我们没有代理呢,该咋整。
- 使用国内镜像才是王道呀!
四、使用国内镜像
- 新建一个配置文件
settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>huaweicloud</id>
<mirrorOf>*</mirrorOf>
<name>huaweicloud</name>
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
</mirror>
<mirror>
<id>tencent</id>
<mirrorOf>*</mirrorOf>
<name>tencent</name>
<url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
</mirror>
<mirror>
<id>163</id>
<mirrorOf>*</mirrorOf>
<name>163</name>
<url>http://mirrors.163.com/maven/repository/maven-public/</url>
</mirror>
</mirrors>
</settings>
- 文件->设置->构建、执行、部署->构建工具->Maven->用户设置文件
五、重新编译验证
- 点击Maven刷新按钮,重新加载所有Maven项目
- Maven Clean
问题解决,撒花🎉~
觉得好,就一键三连呗(点赞+收藏+关注)