Spring集成Llama3时无法找到org.springframework.ai依赖问题
Spring应用集成Llama3时依赖解析失败的解决方法
问题描述
- 按照Spring AI文档尝试集成Llama3,添加依赖
implementation 'org.springframework.ai:spring-ai-ollama-spring-boot-starter'后,构建报错:
Execution failed for task ':compileJava'. > Could not resolve all files for configuration ':compileClasspath'. > Could not find org.springframework.ai:spring-ai-ollama-spring-boot-starter:.
- 修改依赖为
implementation 'org.springframework.experimental.ai:spring-ai-ollama-spring-boot-starter'后,仍出现类似的依赖找不到错误:
Execution failed for task ':compileJava'. > Could not resolve all files for configuration ':compileClasspath'. > Could not find org.springframework.experimental.ai:spring-ai-ollama-spring-boot-starter:
解决步骤
- 指定明确的依赖版本:依赖未声明版本号是核心问题,需添加Spring AI的具体版本号(以实际可用版本为准),示例:
implementation 'org.springframework.ai:spring-ai-ollama-spring-boot-starter:1.0.0-SNAPSHOT' - 配置对应仓库(若用快照版):如果使用SNAPSHOT版本,需要在项目仓库配置中添加Spring快照仓库(以Gradle为例):
repositories { mavenCentral() maven { url 'https://repo.spring.io/snapshot' } } - 修正依赖GroupId:当前Spring AI正式版本的GroupId已统一为
org.springframework.ai,org.springframework.experimental.ai是早期实验阶段的标识,现已废弃,无需使用。 - 确认本地Ollama环境:确保本地已安装启动Ollama服务,并成功拉取Llama3模型,避免后续集成时出现服务连接问题。
内容的提问来源于stack exchange,提问作者Nicolas Othmar
相关产品推荐
相关产品推荐

