跳到主要内容

入门指南

DeepSeek V3 中英对照 Getting Started

本节提供了使用 Spring AI 的入门指南。

您应根据需要按照以下各节中的步骤进行操作。

备注

Spring AI 支持 Spring Boot 3.2.x 和 3.3.x

Spring Initializr

前往 start.spring.io 并选择你希望在新应用程序中使用的 AI 模型和向量存储。

制品仓库

1.0 M6 及之后版本 - 使用 Maven Central

截至 1.0 M6 版本,发布版本已在 Maven Central 上提供。您无需对构建文件进行任何更改。

Pre 1.0 M6 - 添加 Spring 仓库

你需要在你的构建系统中添加 Spring 的里程碑(milestone)和快照(snapshot)仓库。

如果您更喜欢手动添加依赖项代码片段,请按照以下部分的说明操作。

要使用 Milestone 和 Snapshot 版本,你需要在构建文件中添加对 Spring Milestone 和/或 Snapshot 仓库的引用。

将以下仓库定义添加到您的 Maven 或 Gradle 构建文件中:

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
xml

依赖管理

Spring AI 的物料清单(BOM)声明了给定版本的 Spring AI 所使用的所有依赖项的推荐版本。在应用程序的构建脚本中使用 BOM 可以避免您自己指定和维护依赖项版本的需要。相反,您使用的 BOM 版本决定了所使用的依赖项版本。它还确保默认情况下您使用的是经过支持与测试的依赖项版本,除非您选择覆盖它们。

将 BOM 添加到你的项目:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
xml

为特定组件添加依赖

文档中的以下每个部分都展示了您需要添加到项目构建系统中的依赖项。

Spring AI 示例

请参考此页面获取更多与 Spring AI 相关的资源和示例。