Spring AI 1.0.0-M6 快速开始(一)

Spring AI 1.0.0-M6

入门

Spring 是JAVA中我们经常使用的框架之一,Spring AI不断的发展迭代目前已经到M6版本据说上半年会出一个稳定版本。

本节提供了如何开始使用Spring AI的M6。


一、存储库

1.0 M6 -添加Spring存储库

需要将Spring里程碑和快照存储库添加到构建系统中。如果您更喜欢手动添加依赖项片段,请按照以下部分中的说明操作。

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

将以下存储库定义添加到您的Maven构建文件:

xml 复制代码
<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>

二、依赖管理

Spring AI Bill of Materials (BOM) 声明了Spring AI给定版本使用的所有依赖项的推荐版本。 使用应用程序构建脚本中的BOM,无需您自己指定和维护依赖项版本。 相反,您使用的BOM表版本决定了所使用的依赖关系版本。 它还确保您在默认情况下使用依赖项的受支持和测试版本,除非您选择覆盖它们。

将BOM表添加到项目中:

xml 复制代码
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>1.0.0-M6</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

完整maven

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.4.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.qijc</groupId>
	<artifactId>ai-springboot-starting</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>ai-springboot-starting</name>
	<description>ai-springboot-starting</description>

	<properties>
		<java.version>17</java.version>
		<spring-ai.version>1.0.0-M6</spring-ai.version>
	</properties>

	<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>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.ai</groupId>
				<artifactId>spring-ai-bom</artifactId>
				<version>${spring-ai.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

相关推荐
财迅通Ai17 小时前
远信储能(9621.HK)招股开启,AI+储能跑出新范式
大数据·人工智能·远信储能
老金带你玩AI17 小时前
一人公司,单月收入近10万,我做了这三门生意(OPC系列-3)
人工智能
水如烟17 小时前
孤能子视角:AI不是“东西”,是认知库重整理交互系统——从李飞飞“不知道AGI和AI的区别在哪里”说起:知识增量与应用增量是两个判据层
人工智能
云-缩影17 小时前
拆解函数计算 Serverless GPU 部署 AI 模型:Flux 生图和语音复刻怎么跑的
人工智能·云原生·serverless
zcg194217 小时前
通过UE制作segment和depth数据
人工智能·深度学习
一只鹿鹿鹿17 小时前
智算算力、AI-芯片与产品解析(PPT文件)
大数据·运维·网络·人工智能·物联网·1024程序员节
鱼宵17 小时前
取集合第一个元素,Java 为什么要写三种写法?
java·windows·python·java21
卷无止境17 小时前
给AI装上一双眼睛:快速构建代码验证器的思路与落地方案
后端·python
stormzhangV17 小时前
科普下 AI 降智
人工智能·aigc
懿路向前17 小时前
唤醒工作台全实录(一):立项——化性起伪与三条设计原则
人工智能·华为