SpringAI Agent 开发实战:利用 Skills 增强 Java 应用智能能力
最近 AI 相关话题中,Claude Skills 非常火爆。SpringAI 迅速支持了 Skills 机制,这让 Java 开发者也能快速构建具备特定能力的智能体。
本文将通过构建一个代码评审(Code Reviewer)Agent,演示如何将 SpringAI 和 Skills 结合起来使用。
环境准备与项目初始化
基础环境要求
要体验 SpringAI & Skills,建议升级到 SpringAI 2.x 版本,同时 SpringBoot 可升级至 4.x。
- SpringAI: 2.0.0-M2
- JDK: 21
- SpringBoot: 4.0.1
除了基本依赖外,还需要选择一个支持 Function Tool 的大模型作为核心。这里选择智谱的 GLM-4.5-Flash,因其免费且效果不错,适合体验。
项目依赖配置
创建一个标准的 SpringAI 应用,在 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

