聊聊Spring AI 1.0.0-SNAPSHOT的变更

本文主要研究一下Spring AI 1.0.0-SNAPSHOT的变更

Artifact ID变更

  • Model starters: spring-ai-{model}-spring-boot-starter → spring-ai-starter-model-{model}
  • Vector Store starters: spring-ai-{store}-store-spring-boot-starter → spring-ai-starter-vector-store-{store}
  • MCP starters: spring-ai-mcp-{type}-spring-boot-starter → spring-ai-starter-mcp-{type}

示例

<!-- BEFORE -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>

<!-- AFTER -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>

Spring AI Autoconfiguration从单体模块变更为每个model、vector-store等独立的autoconfiguration,拆开的目的就是避免引入没必要的依赖,减少冲突风险:

<!-- NO LONGER AVAILABLE -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-spring-boot-autoconfigure</artifactId>
    <version>${project.version}</version>
</dependency>

取而代之的是:

  • Model autoconfiguration: spring-ai-autoconfigure-model-{model}
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-model-openai</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-model-anthropic</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-model-vertex-ai</artifactId>
</dependency>
  • Vector Store autoconfiguration: spring-ai-autoconfigure-vector-store-{store}
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-vector-store-redis</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-vector-store-pgvector</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-vector-store-chroma</artifactId>
</dependency>
  • MCP autoconfiguration: spring-ai-autoconfigure-mcp-{type}
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-mcp-client</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-autoconfigure-mcp-server</artifactId>
</dependency>

Package Name变更

  • KeywordMetadataEnricher以及SummaryMetadataEnricher从org.springframework.ai.transformer变更到org.springframework.ai.chat.transformer
  • Content, MediaContent以及Media从org.springframework.ai.model变更到org.springframework.ai.content

Module变更

之前是所有的都在spring-ai-core,现在拆分到具体的领域模块来减少不必要的依赖,如下:

  • spring-ai-commons包含了核心的model比如DocumentTextSplitter
  • spring-ai-model包含了AI能力的相关抽象,比如ChatModelEmbeddingModelImageModelToolDefinitionToolCallback
  • spring-ai-vector-store统一了向量数据库的抽象VectorStore,提供了SimpleVectorStore便于内存使用
  • spring-ai-client-chat提供了high-level的AI会话API,比如ChatClientChatMemoryOutputConverter
  • spring-ai-advisors-vector-store为RAG衔接了chat和向量数据库,比如QuestionAnswerAdvisorVectorStoreChatMemoryAdvisor
  • spring-ai-model-chat-memory-cassandra提供了CassandraChatMemory
  • spring-ai-rag提供了RAG的pipelines,比如RetrievalAugmentationAdvisor

Dependency Structure变更如下:

  • spring-ai-commons (foundation)
  • spring-ai-model (depends on commons)
  • spring-ai-vector-store and spring-ai-client-chat (both depend on model)
  • spring-ai-advisors-vector-store and spring-ai-rag (depend on both client-chat and vector-store)
  • spring-ai-model-chat-memory-* modules (depend on client-chat)

小结

Spring AI 1.0.0-SNAPSHOT主要是涉及了Artifact ID, Package, Module的变更;Spring AI Autoconfiguration从单体模块变更为每个model、vector-store等独立的autoconfiguration,拆开的目的就是避免引入没必要的依赖,减少冲突风险;KeywordMetadataEnricher、SummaryMetadataEnricher、Content、MediaContent以及Media涉及了包名的变更;模块的变更将spring-ai-core拆分到具体的领域模块来减少不必要的依赖。

doc

### 解决 Maven 项目中 `org.springframework.ai:spring-ai-ollama-spring-boot-starter:1.0.0-SNAPSHOT` 依赖无法解析的问题 当遇到 Maven 依赖无法解析的情况时,通常是因为本地仓库缓存、远程仓库配置不当或版本号错误等原因造成的。针对当前问题,可以采取以下措施来解决问题。 #### 检查 POM 文件中的依赖声明 确认项目的 pom.xml 中是否正确指定了所需的依赖项以及对应的版本号。对于 `spring-ai-ollama-spring-boot-starter` 的 SNAPSHOT 版本,应该像这样定义: ```xml <dependency> <groupId>org.springframework.ai</groupId> <artifactId>spring-ai-ollama-spring-boot-starter</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> ``` #### 配置正确的仓库地址 由于 Spring AI 是较新的技术栈,可能默认的中央库并不包含这些资源。因此需要向 settings.xml 或者 pom.xml 添加额外的镜像源支持。例如阿里云提供的开源软件托管服务可以帮助加速下载速度并提高成功率[^1]。 ```xml <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>https://maven.aliyun.com/repository/spring-plugin/</url> </mirror> </mirrors> ``` 注意这里使用的 URL 应该指向包含了所需组件的具体路径而不是普通的公共组。 #### 清理本地仓储数据 有时候旧的数据会干扰新请求的成功执行,所以建议清理掉 .m2 下面的相关文件夹后再尝试重新构建工程。这可以通过命令行工具 mvn 来完成操作: ```bash mvn clean install -U ``` 参数 `-U` 表示强制更新快照版依赖。 #### 更新 IDE 设置 如果是在 IDEA 这样的集成开发环境中工作,则还需要确保其内部设置也同步修改过来了。具体来说就是 Project Structure -> Modules -> Dependencies Tab 页面里边要能看见刚才加入的新条目;另外 Build, Execution, Deployment -> Build Tools -> Maven -> Repositories 节点下也要有相应的 Repository Entry 存在[^2]。 通过以上方法应当能够有效处理此类 maven 依赖找不到的问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值