nacos导入依赖报错:Non-resolvable import POM: The following artifacts could not be resolved: *****
·
nacos导入依赖报错:Non-resolvable import POM: The following artifacts could not be resolved: *****
报错如下:
Non-resolvable import POM: The following artifacts could not be resolved: org.springframework.cloud:spring-cloud-dependencies:pom:2023.0.0 (absent): org.springframework.cloud:spring-cloud-dependencies:pom:2023.0.0 failed to transfer from http://maven.aliyun.com/nexus/content/repositories/central/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of alimaven has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.cloud:spring-cloud-dependencies:pom:2023.0.0 from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/): Connect to maven.aliyun.com:80 [maven.aliyun.com/120.39.197.154, maven.aliyun.com/120.39.197.157, maven.aliyun.com/120.39.197.148, maven.aliyun.com/120.39.197.155, maven.aliyun.com/120.39.197.153, maven.aliyun.com/120.39.197.156, maven.aliyun.com/120.39.197.152, maven.aliyun.com/120.39.197.149] failed: Connect timed out
报错核心原因
- 警告:spring-boot-maven-plugin 缺少版本号(不致命,但建议修复)
- 致命错误
- Spring Cloud 2023.0.0 版本无法从阿里云镜像下载(连接超时)
- Maven 缓存了失败记录,不会自动重试
- 关键:Spring Cloud 2023.0.0 必须搭配 Spring Boot 3.1.x 版本,版本不匹配也会导致依赖异常
解决方法1
解决方案
步骤 1:修复 pom.xml 配置(最核心)
替换你的 pom.xml 中 父工程、Spring Cloud、build 插件 配置,我给你写好兼容版:
<!-- 1. 父工程:Spring Boot 3.1.7(和 Spring Cloud 2023.0.0 完美兼容) -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.7</version>
<relativePath/>
</parent>
<!-- 2. 版本属性 -->
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<!-- 3. Spring Cloud 依赖管理(固定写法) -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 4. 修复插件:添加版本号,解决警告 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 必须和父工程 Spring Boot 版本一致 -->
<version>3.1.7</version>
</plugin>
</plugins>
</build>
步骤 2:更新阿里云镜像地址(旧地址已失效!)
你用的 http://maven.aliyun.com/nexus/… 是废弃地址,会直接超时!
打开你的 Maven 配置文件:
- 全局配置:maven/conf/settings.xml
- 用户配置:C:\Users\你的用户名.m2\settings.xml
替换为最新阿里云镜像:
<mirrors>
<mirror>
<id>aliyunmaven</id>
<name>阿里云公共仓库</name>
<url>http://central.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
解决方案2
-
如果问题持续,尝试在浏览器中直接访问报错的依赖URL ,确认仓库是否可达。
-
如果无法到达,即仓库地址错误,如:https://maven.aliyun.com/repository/public 等地址无法到达,会出现404页面

-
清理并重新下载
mvn clean install -U
- 重新刷新mavean,就可以了
更多推荐


所有评论(0)