Skip to content

qdcxj/qdcxj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

🌟 Spring AI Demo 项目

基于 Spring Boot 3.x 和 Spring AI 构建的现代化人工智能应用演示项目


📋 目录


🛠️ 技术栈

分类 技术 版本
语言 Java 21
框架 Spring Boot 3.5.14
AI 框架 Spring AI 1.1.5
向量数据库 PostgreSQL + PgVector 14+
API 文档 SpringDoc OpenAPI 2.5.0
AI 服务 阿里云 DashScope -

🚀 快速开始

环境要求

  • ✅ JDK 21+
  • ✅ Maven 3.8+
  • ✅ PostgreSQL 14+(需安装 pgvector 扩展)

数据库配置

-- 1. 创建数据库
CREATE DATABASE demo_db;

-- 2. 连接数据库
\c demo_db;

-- 3. 安装 pgvector 扩展
CREATE EXTENSION vector;

配置文件

编辑 src/main/resources/application.yaml

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/demo_db
    username: your_username
    password: your_password
  
  ai:
    dashscope:
      api-key: your_dashscope_api_key  # 阿里云 DashScope API Key

启动应用

# 方式一:使用 Maven Wrapper 直接运行
./mvnw spring-boot:run

# 方式二:打包后运行
./mvnw clean package
java -jar target/demo-0.0.1-SNAPSHOT.jar

📁 项目结构

src/main/java/com/cxj/ai/
├── DemoApplication.java           # 🌱 启动类
├── config/
│   └── SwaggerConfig.java         # 📝 Swagger 配置类
└── runner/
    └── SwaggerUrlPrinter.java     # 🖨️ 启动时打印 Swagger 地址

✨ 功能特性

功能 状态 描述
Spring AI 集成 完整集成 Spring AI 框架
DashScope 支持 支持阿里云大模型服务
PgVector 存储 向量数据库持久化
API 文档 Swagger UI 自动生成
启动提示 自动打印访问地址

📖 API 文档

启动应用后,访问以下地址查看 API 文档:

地址 描述
http://localhost:8080/swagger-ui.html Swagger UI 界面
http://localhost:8080/api-docs OpenAPI JSON 格式
http://localhost:8080/api-docs.yaml OpenAPI YAML 格式

⚙️ 配置说明

数据库配置

参数 说明 默认值
spring.datasource.url 数据库连接地址 jdbc:postgresql://localhost:5432/demo_db
spring.datasource.username 数据库用户名 -
spring.datasource.password 数据库密码 -

AI 配置

参数 说明
spring.ai.dashscope.api-key 阿里云 DashScope API Key

💡 开发指南

代码规范

  • 遵循 Spring Boot 编码规范
  • 使用 Lombok 简化代码
  • 配置类统一放在 config/ 目录
  • Runner 类统一放在 runner/ 目录

构建命令

# 编译项目
./mvnw compile

# 运行测试
./mvnw test

# 打包(跳过测试)
./mvnw clean package -DskipTests

# 查看依赖树
./mvnw dependency:tree

📄 License

MIT License

Copyright (c) 2026 CXJ AI Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Made with ❤️ by CXJ AI Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors