SpringAI Agent 开发实战:利用 Skills 构建智能应用
最近 AI 领域最火的话题莫过于 Claude Skills,让人惊喜的是 SpringAI 迅速跟进支持了 Skills。这意味着 Java 开发者也能快速跟上 AI 应用的工程化浪潮。
本文将通过构建一个代码评审 Agent,演示如何将 SpringAI 与 Skills 结合使用,实现大模型对特定任务的语义匹配与工具调用。
一、环境准备与项目搭建
要体验 SpringAI & Skills,建议升级到 SpringAI 2.x 版本,同时 SpringBoot 可升级至 4.x。
1. 基础依赖
- SpringAI: 2.0.0-M2
- JDK: 21
- SpringBoot: 4.0.1
除了基本依赖,我们需要选择一个支持 Function Tool 的大模型作为核心。这里选用智谱的 GLM-4.5-Flash,免费且效果不错。
2. Maven 配置
在 pom.xml 中引入核心依赖:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.1</version>
<relativePath/>
</parent>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-ai.version>2.0.0-M2</spring-ai.version>
</properties>
<>
org.springframework.ai
spring-ai-bom
${spring-ai.version}
pom
import
spring-snapshots
Spring Snapshots
https://repo.spring.io/snapshot
false
Central Portal Snapshots
central-portal-snapshots
https://central.sonatype.com/repository/maven-snapshots/
false
true
org.springaicommunity
spring-ai-agent-utils
0.4.1
org.springframework.ai
spring-ai-starter-model-zhipuai


