You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
356 lines
16 KiB
356 lines
16 KiB
<?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.5.8</version>
|
|
<relativePath/>
|
|
</parent>
|
|
<groupId>com.cdw</groupId>
|
|
<artifactId>chat-bot</artifactId>
|
|
<version>0.0.1-SNAPSHOT</version>
|
|
<name>智能客服</name>
|
|
<properties>
|
|
<java.version>17</java.version>
|
|
<!-- Spring AI BOM 版本(统一管理 org.springframework.ai 全部依赖) -->
|
|
<spring-ai.version>1.1.2</spring-ai.version>
|
|
<!-- Spring AI Alibaba 版本(1.1.2.2 官方基线 = Boot 3.5.8 + Spring AI 1.1.2) -->
|
|
<spring-ai-alibaba.version>1.1.2.2</spring-ai-alibaba.version>
|
|
<!-- 设置为 true 可跳过前端 SDK 构建,加快后端编译:mvn compile -Dskip.frontend=true -->
|
|
<skip.frontend>false</skip.frontend>
|
|
</properties>
|
|
|
|
<!-- ==================== Maven 多环境 Profile ==================== -->
|
|
<!-- 通过 -P 参数选择目标环境:mvn clean package -P test / -P prod;不传则默认 dev -->
|
|
<!-- 每个 profile 通过 profiles.active 属性标识当前环境,打包时会替换 application.yml 中的 @profiles.active@ 占位符 -->
|
|
<profiles>
|
|
<profile>
|
|
<!-- 本地开发环境(默认激活) -->
|
|
<id>dev</id>
|
|
<properties>
|
|
<profiles.active>dev</profiles.active>
|
|
</properties>
|
|
<activation>
|
|
<activeByDefault>true</activeByDefault>
|
|
</activation>
|
|
</profile>
|
|
<profile>
|
|
<!-- 生产环境 -->
|
|
<id>prod</id>
|
|
<properties>
|
|
<profiles.active>prod</profiles.active>
|
|
</properties>
|
|
</profile>
|
|
</profiles>
|
|
<dependencyManagement>
|
|
<dependencies>
|
|
<!-- Spring AI BOM:统一管理所有 Spring AI 依赖版本 -->
|
|
<!-- 注意:不导入 spring-ai-alibaba-bom,因其 dependencyManagement 不包含
|
|
spring-ai-alibaba-starter-dashscope,导入后仍需显式写版本号,无收益 -->
|
|
<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>
|
|
<dependencies>
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-web</artifactId>
|
|
</dependency>
|
|
|
|
<!-- 确保包含日志支持 -->
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-logging</artifactId>
|
|
</dependency>
|
|
|
|
<!-- Spring AI Alibaba DashScope(通义千问)- 新版 starter,替代老版 spring-ai-alibaba-starter -->
|
|
<!-- 必须显式写版本号:spring-ai-alibaba-bom 并不管理本模块 -->
|
|
<dependency>
|
|
<groupId>com.alibaba.cloud.ai</groupId>
|
|
<artifactId>spring-ai-alibaba-starter-dashscope</artifactId>
|
|
<version>${spring-ai-alibaba.version}</version>
|
|
</dependency>
|
|
|
|
<!-- Spring AI OpenAI(用于接入 OpenAI 兼容提供商:DeepSeek / Kimi / 豆包 / 智谱) -->
|
|
<dependency>
|
|
<groupId>org.springframework.ai</groupId>
|
|
<artifactId>spring-ai-openai</artifactId>
|
|
</dependency>
|
|
|
|
<!-- Spring AI MCP Client(Model Context Protocol 客户端) -->
|
|
<!-- 必须排除传递引入的 MCP SDK 并显式锁定 0.18.3,切勿删除:
|
|
Spring AI 1.1.2 的 spring-ai-mcp 仍锁定 MCP SDK 0.17.0,而 0.17.0 的 JsonMapper
|
|
包名是 io.modelcontextprotocol.json.jackson(无 jackson2),
|
|
本项目 McpClientManager 使用的是 0.18.0 起才有的 ...json.jackson2.JacksonMcpJsonMapper,
|
|
不锁版本会直接编译失败。0.18.3 已修复 SSE 400 + 超时问题。
|
|
安全性:spring-ai-mcp 1.1.2 仅引用 McpSyncClient/McpAsyncClient/McpClient/
|
|
McpTransportContext/McpSchema/Assert,这些类 0.18.3 均存在。 -->
|
|
<dependency>
|
|
<groupId>org.springframework.ai</groupId>
|
|
<artifactId>spring-ai-starter-mcp-client</artifactId>
|
|
<exclusions>
|
|
<exclusion>
|
|
<groupId>io.modelcontextprotocol.sdk</groupId>
|
|
<artifactId>mcp</artifactId>
|
|
</exclusion>
|
|
</exclusions>
|
|
</dependency>
|
|
|
|
<!-- 显式引入新版 MCP SDK(覆盖 spring-ai-mcp 传递的 0.17.0) -->
|
|
<dependency>
|
|
<groupId>io.modelcontextprotocol.sdk</groupId>
|
|
<artifactId>mcp</artifactId>
|
|
<version>0.18.3</version>
|
|
</dependency>
|
|
|
|
<!--Hutool 工具库-->
|
|
<dependency>
|
|
<groupId>cn.hutool</groupId>
|
|
<artifactId>hutool-all</artifactId>
|
|
<version>5.8.41</version>
|
|
</dependency>
|
|
<!-- SFTP 客户端(附件上传到 SFTP 服务器) -->
|
|
<dependency>
|
|
<groupId>com.jcraft</groupId>
|
|
<artifactId>jsch</artifactId>
|
|
<version>0.1.55</version>
|
|
</dependency>
|
|
<!--Knife4j 接口文档-->
|
|
<dependency>
|
|
<groupId>com.github.xiaoymin</groupId>
|
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
|
<version>4.5.0</version>
|
|
</dependency>
|
|
<!-- 结构化输出:victools jsonschema-generator 已由 spring-ai-model 传递引入(4.38.0),
|
|
项目不再显式声明(显式声明曾导致 4.38.0/4.37.0 版本混用) -->
|
|
<!-- Token 分词:OverlapTokenTextSplitter 直接使用(与 Spring AI TokenTextSplitter 同库同版本) -->
|
|
<dependency>
|
|
<groupId>com.knuddels</groupId>
|
|
<artifactId>jtokkit</artifactId>
|
|
<version>1.1.0</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.springframework.ai</groupId>
|
|
<artifactId>spring-ai-markdown-document-reader</artifactId>
|
|
</dependency>
|
|
<!-- Lombok 版本交由 Spring Boot 父 POM 托管(3.5.8 管理 1.18.42) -->
|
|
<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>
|
|
<!-- 手动整合 PGVector 向量存储 -->
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.postgresql</groupId>
|
|
<artifactId>postgresql</artifactId>
|
|
<scope>runtime</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>org.springframework.ai</groupId>
|
|
<artifactId>spring-ai-pgvector-store</artifactId>
|
|
</dependency>
|
|
<!-- spring-ai-tika-document-reader -->
|
|
<dependency>
|
|
<groupId>org.springframework.ai</groupId>
|
|
<artifactId>spring-ai-tika-document-reader</artifactId>
|
|
</dependency>
|
|
<!-- Spring Security 认证授权框架 -->
|
|
<dependency>
|
|
<groupId>org.springframework.boot</groupId>
|
|
<artifactId>spring-boot-starter-security</artifactId>
|
|
</dependency>
|
|
|
|
<!-- JWT(JJWT 库):用于无状态 Token 认证 -->
|
|
<dependency>
|
|
<groupId>io.jsonwebtoken</groupId>
|
|
<artifactId>jjwt-api</artifactId>
|
|
<version>0.12.7</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>io.jsonwebtoken</groupId>
|
|
<artifactId>jjwt-impl</artifactId>
|
|
<version>0.12.7</version>
|
|
<scope>runtime</scope>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>io.jsonwebtoken</groupId>
|
|
<artifactId>jjwt-jackson</artifactId>
|
|
<version>0.12.7</version>
|
|
<scope>runtime</scope>
|
|
</dependency>
|
|
|
|
<!-- 说明:spring-security-oauth2-client 补丁依赖已移除。
|
|
Spring AI 1.0.1 的 ToolCallingAutoConfiguration 曾硬引用 oauth2-client 类导致
|
|
ClassNotFoundException;1.1.2 已无该耦合(已核对字节码常量池零 oauth2 引用),
|
|
且 ToolCallingManager Bean 仍由 spring-ai-autoconfigure-model-tool 提供。
|
|
若启动仍报相关类缺失,再按需加回。 -->
|
|
|
|
<dependency>
|
|
<groupId>com.baomidou</groupId>
|
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
|
<version>3.5.14</version>
|
|
</dependency>
|
|
</dependencies>
|
|
|
|
<build>
|
|
<!-- 打包产物按环境区分文件名,如 supportbot-dev.jar / supportbot-test.jar / supportbot-prod.jar -->
|
|
<finalName>supportbot-${profiles.active}</finalName>
|
|
<!-- 开启资源过滤:使 application.yml 中的 @profiles.active@ 占位符在打包时被替换为实际环境 -->
|
|
<!-- Spring Boot 父 POM 默认使用 @...@ 作为过滤占位符,不会误伤 yml 中的 ${...} -->
|
|
<resources>
|
|
<resource>
|
|
<directory>src/main/resources</directory>
|
|
<filtering>true</filtering>
|
|
<excludes>
|
|
<exclude>static/**</exclude>
|
|
</excludes>
|
|
</resource>
|
|
<resource>
|
|
<directory>src/main/resources/static</directory>
|
|
<!-- 必须指定 targetPath,否则文件会被平铺到 target/classes/ 根目录,而不是 target/classes/static/ -->
|
|
<targetPath>static</targetPath>
|
|
<filtering>false</filtering>
|
|
</resource>
|
|
</resources>
|
|
<plugins>
|
|
<!-- 默认跳过集成测试(所有测试均为 @SpringBootTest,需要 DB 和 API Key) -->
|
|
<!-- 需要运行测试时显式指定:mvn test -DskipTests=false -->
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-surefire-plugin</artifactId>
|
|
<configuration>
|
|
<skipTests>true</skipTests>
|
|
</configuration>
|
|
</plugin>
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
<configuration>
|
|
<annotationProcessorPaths>
|
|
<path>
|
|
<groupId>org.projectlombok</groupId>
|
|
<artifactId>lombok</artifactId>
|
|
<!-- 使用 Boot 父 POM 托管的 ${lombok.version},与运行时版本保持一致 -->
|
|
<version>${lombok.version}</version>
|
|
</path>
|
|
</annotationProcessorPaths>
|
|
</configuration>
|
|
</plugin>
|
|
|
|
<!-- ==================== 前端构建 ==================== -->
|
|
<!-- 在项目根目录安装 Node.js(仅首次),然后通过 build-all.mjs 并行编译 client + frontend -->
|
|
<!-- 统一绑定到 prepare-package 阶段,mvn compile 不触发,mvn package/install 才构建 -->
|
|
<!-- 跳过前端构建:mvn package -Dskip.frontend=true -->
|
|
<plugin>
|
|
<groupId>com.github.eirslett</groupId>
|
|
<artifactId>frontend-maven-plugin</artifactId>
|
|
<version>1.15.1</version>
|
|
<configuration>
|
|
<workingDirectory>${project.basedir}</workingDirectory>
|
|
<skip>${skip.frontend}</skip>
|
|
</configuration>
|
|
<executions>
|
|
<!-- 安装 Node.js(仅首次下载,后续复用缓存) -->
|
|
<execution>
|
|
<id>install-node-and-npm</id>
|
|
<phase>prepare-package</phase>
|
|
<goals>
|
|
<goal>install-node-and-npm</goal>
|
|
</goals>
|
|
<configuration>
|
|
<nodeVersion>v20.18.0</nodeVersion>
|
|
</configuration>
|
|
</execution>
|
|
</executions>
|
|
</plugin>
|
|
|
|
<!-- 调用 build-all.mjs 并行执行 client + frontend 的 npm install 和 build -->
|
|
<plugin>
|
|
<groupId>org.codehaus.mojo</groupId>
|
|
<artifactId>exec-maven-plugin</artifactId>
|
|
<version>3.5.0</version>
|
|
<executions>
|
|
<execution>
|
|
<id>build-frontend-all</id>
|
|
<phase>prepare-package</phase>
|
|
<goals>
|
|
<goal>exec</goal>
|
|
</goals>
|
|
<configuration>
|
|
<skip>${skip.frontend}</skip>
|
|
<executable>node</executable>
|
|
<workingDirectory>${project.basedir}</workingDirectory>
|
|
<arguments>
|
|
<argument>${project.basedir}/build-all.mjs</argument>
|
|
</arguments>
|
|
</configuration>
|
|
</execution>
|
|
</executions>
|
|
</plugin>
|
|
|
|
<!-- 复制 SDK 构建产物到 Spring Boot 静态资源目录(frontend 产物已由 postbuild 脚本复制到 static/) -->
|
|
<plugin>
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
<artifactId>maven-resources-plugin</artifactId>
|
|
<configuration>
|
|
<!-- 使用 @ 作为过滤分隔符(与 Spring Boot 父 POM 一致) -->
|
|
<!-- 避免与 yml/properties 中的 ${...} Spring 占位符冲突 -->
|
|
<delimiters>
|
|
<delimiter>@</delimiter>
|
|
</delimiters>
|
|
<useDefaultDelimiters>false</useDefaultDelimiters>
|
|
</configuration>
|
|
<executions>
|
|
<execution>
|
|
<id>copy-sdk-to-static</id>
|
|
<phase>prepare-package</phase>
|
|
<goals>
|
|
<goal>copy-resources</goal>
|
|
</goals>
|
|
<configuration>
|
|
<outputDirectory>${project.basedir}/src/main/resources/static/sdk</outputDirectory>
|
|
<resources>
|
|
<resource>
|
|
<directory>${project.basedir}/client/dist</directory>
|
|
<includes>
|
|
<include>chatbot-sdk.js</include>
|
|
<include>chatbot-sdk.min.js</include>
|
|
</includes>
|
|
</resource>
|
|
</resources>
|
|
</configuration>
|
|
</execution>
|
|
</executions>
|
|
</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>
|
|
</project>
|