SpringAI Agent 实战:利用 Skills 构建代码评审智能体
最近 AI 领域最火的话题无疑是 Claude Skills,令人惊喜的是 SpringAI 迅速跟进支持了 Skills 机制。这意味着 Java 开发者在 AI 应用开发上也能快速跟上节奏,复用现有的工程化思维。
本文将通过构建一个 Code Reviewer(代码审查员),演示如何将 SpringAI 与 Skills 结合使用,实现模块化的智能体能力。
一、环境准备与项目搭建
要体验 SpringAI & Skills,建议升级到较新的版本组合。目前推荐配置如下:
- SpringAI: 2.0.0-M2
- JDK: 21
- SpringBoot: 4.0.1
除了基础依赖,还需要选择一个支持 Function Tool 的大模型作为核心。这里选用智谱的 GLM-4.5-Flash,免费且效果稳定,适合快速验证。
1. 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>
<dependencyManagement>
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


