SpringAI maven导入报错 【Non-resolvable import POM: The following artifacts could not be resolved】

BUGFIX 【修复SpringAI导入maven报错】

1. 问题概述

版本

  1. idea 2025.1.1.1
  2. maven 3.9.6
  3. spring AI 0.8.1

报错截图

Non-resolvable import POM: The following artifacts could not be resolved: org.springframework.ai:spring-ai-bom:pom:0.8.1 (absent): org.springframework.ai:spring-ai-bom:pom:0.8.1 failed to transfer from https://repo.spring.io/milestone during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spring-milestones has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.ai:spring-ai-bom:pom:0.8.1 from/to spring-milestones (https://repo.spring.io/milestone): repo.spring.io

2. 复现

<properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-ai.version>0.8.1</spring-ai.version>
</properties>

问题原因分析

  1. Maven 将下载失败的状态缓存了,因此不会重新尝试,除非强制刷新或等待缓存超时
  2. 阿里云 Maven 镜像 并未托管该版本或该组件

3. 修复方案

强制刷新maven缓存

mvn clean install -U
  • -U 参数会强制更新所有 SNAPSHOT 和 RELEASE 依赖。

确认是否真实存在

阿里云仓库文档: https://developer.aliyun.com/mvn/guide
在这里插入图片描述
应该爬的maven的仓库
搜索maven的仓库:https://search.maven.org/search?q=spring-ai-bom
在这里插入图片描述
没有0.8.1版本
故修改1.0.0.M6

<properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-ai.version>1.0.0-M6</spring-ai.version>
</properties>

刷新maven, 成功无报错

总结

阿里云 Maven 镜像虽然在国内速度快,但存在同步不完整问题,特别是 Spring Boot、Spring AI、Spring Cloud 的较新版本经常无法及时同步。

在重要项目中,建议保留官方 Maven 仓库或用私服(如 Nexus)中转。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值