Spring AI Alibaba接入大模型時(shí)的依賴問(wèn)題小結(jié)
(一)pom.xml文件:
首先,要導(dǎo)入maven主倉(cāng)庫(kù)中未存儲(chǔ)的依賴。
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>其次,要在<dependencies>中追加下列依賴。
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter</artifactId>
<version>1.0.0-M3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>最后,需要檢查spring ai版本是否與springboot版本相適配,我的springboot版本是3.4.2,spring ai版本是1.0.0-M3.2,jdk版本是jdk-17。全部的pom.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.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.alichat</groupId>
<artifactId>alibabaChatModel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>alibabaChatModel</name>
<description>alibabaChatModel</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter</artifactId>
<version>1.0.0-M3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>(二)application.yml配置文件
主要配置自己的api-key,代碼如下:
server:
port: 8001
spring:
application:
name: alibabaChatModel
ai:
dashscope:
api-key: sk-XXX
chat:
client:
enabled: true在配置依賴時(shí)的注意事項(xiàng):最好將maven倉(cāng)庫(kù)下載到本地,換源使用aliyun鏡像,可以明顯地提升pom依賴的各個(gè)jar文件的下載速度!
到此這篇關(guān)于Spring AI Alibaba接入大模型時(shí)的依賴問(wèn)題的文章就介紹到這了,更多相關(guān)Spring AI Alibaba大模型內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Spring?Boot?項(xiàng)目中?JPA?語(yǔ)法的基本使用方法
這篇文章主要介紹了?Spring?Boot?項(xiàng)目中?JPA?語(yǔ)法的基本使用方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-10-10
Android設(shè)備如何保證數(shù)據(jù)同步寫(xiě)入磁盤(pán)的實(shí)現(xiàn)
這篇文章主要介紹了Android設(shè)備如何保證數(shù)據(jù)同步寫(xiě)入磁盤(pán)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
SpringBoot項(xiàng)目導(dǎo)出jar包及瘦身部署方式
今天項(xiàng)目要求Nginx+jar包運(yùn)行多個(gè)項(xiàng)目,在此記錄一下部署的過(guò)程,其中借鑒了好多網(wǎng)上前輩的經(jīng)驗(yàn),感謝各位的無(wú)私分享2024-07-07
解決idea中debug工具欄消失后如何顯示的問(wèn)題
這篇文章主要介紹了解決idea中debug工具欄消失后如何顯示的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-02-02
mybatis對(duì)傳入基本類型參數(shù)的判斷方式
這篇文章主要介紹了mybatis對(duì)傳入基本類型參數(shù)的判斷方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-03-03
Java 網(wǎng)絡(luò)爬蟲(chóng)新手入門詳解
這篇文章主要介紹了Java 網(wǎng)絡(luò)爬蟲(chóng)新手入門詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10

