diff --git a/.gitignore b/.gitignore index f1fd368..259b0e2 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ tmp/ .idea/ .vscode/ *.iml +.classpath +.project +.settings/ # 系统与编辑器临时文件 .DS_Store diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..ffcab66 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/docs/LLMChangeMemory/任务-002-交付文档.md b/docs/LLMChangeMemory/任务-002-交付文档.md index f93584e..19bb3e3 100644 --- a/docs/LLMChangeMemory/任务-002-交付文档.md +++ b/docs/LLMChangeMemory/任务-002-交付文档.md @@ -1,17 +1,127 @@ # 任务 002 交付文档 -状态:待执行代理补交 +- 任务单:`docs/LLMChangeMemory/任务-002-构建基线与最小后端骨架.md` +- 执行时间:2026-11-02 10:3x–10:5x(Asia/Shanghai) +- 执行代理:执行代理 +- 核查方式:仅新增工程骨架文件 + 只读构建验证;未安装系统软件、未改机器级/用户级环境变量、未提交、未推送 -变更文件: +## 状态 -实现摘要: +已验收(主代理复核:2026-11-02;任务单 5 条验收标准全部通过) -版本确认: +主代理验收结论: -实际验证命令及结果: +- 复核 `pom.xml`、Wrapper、应用入口、配置和测试,变更与任务范围一致。 +- 使用任务 001 核实的 JDK 21 入口复跑 `mvnw.cmd -B test`:2 项测试通过。 +- 使用 JDK 17 入口复跑 `mvnw.cmd -B validate`:被 Enforcer 明确拒绝,未静默通过。 +- 复跑 `mvnw.cmd -B package`:成功;启动 jar 后真实访问 `/actuator/health` 返回 HTTP 200 和 `{"status":"UP"}`。 +- 已执行 `mvnw.cmd -B clean`,构建产物和临时健康检查文件已清理。 +- Mockito 动态 agent 警告不影响本任务验收,记录为后续测试基线风险。 +- 任务通过。数据库、Flyway、NapCat 和前端均按任务边界留待后续任务。 -未执行验证: +## 变更文件 -未解决问题 / 风险: +新增: -与任务范围的偏差: +- `pom.xml`:单模块工程,`com.qlinker:qlinker-server:0.0.1-SNAPSHOT`,parent 为 `spring-boot-starter-parent:3.5.16`;依赖 `spring-boot-starter-web`、`spring-boot-starter-actuator`、`spring-boot-starter-test`(test);`java.version=21` + `maven.compiler.release=21`;`maven-enforcer-plugin:3.6.3` 在 `validate` 阶段强制 `requireJavaVersion=[21,)` 与 `requireMavenVersion=[3.9.9,4.0.0)`;`spring-boot-maven-plugin` 负责可执行 jar 打包。 +- `mvnw`、`mvnw.cmd`、`.mvn/wrapper/maven-wrapper.properties`:Maven Wrapper 插件 3.3.4 生成,`distributionType=only-script`,`distributionUrl` 固定 Apache Maven 3.9.9。 +- `src/main/java/com/qlinker/QLinkerApplication.java`:最小应用入口(根包 `com.qlinker`)。 +- `src/main/resources/application.yml`:默认端口 8080、应用名 `qlinker-server`、Actuator 仅暴露 `health` 且不展示明细。 +- `src/test/java/com/qlinker/QLinkerApplicationTests.java`:Spring Boot 上下文测试。 +- `src/test/java/com/qlinker/HealthEndpointTests.java`:`GET /actuator/health` 断言 HTTP 200 且 `status=UP`(MockMvc,不启真实端口)。 + +修改: + +- `.gitignore`:仅新增 3 行工程相关忽略项(`.classpath`、`.project`、`.settings/`)。原因:生成 Wrapper 期间工程根目录出现 Eclipse/m2e 侧文件(`.classpath`、`.project`、`.settings/`,由 IDE Java 语言服务器写入),属机器侧临时产物,不应入库。**未删除这些既有文件**,仅忽略。 + +无其他文件改动。`docs/LLMChangeMemory/任务索引.md` 未修改(按 AGENTS.md 26 章由主代理验收后更新)。 + +## 实现摘要 + +单 Maven 工程 + Maven Wrapper 固定 3.9.9,不依赖 PATH 中的 Maven。Spring Boot 3.5.16 保守线,仅引入 web/actuator/test 三个 starter;未引入 Flyway、MySQL 驱动、MinIO SDK、NapCat 客户端或任何前端依赖,符合任务单「不做」清单。应用无数据库/对象存储/外部中间件依赖,默认配置即可启动,健康检查由 Actuator 提供。 + +JDK 兜底策略(任务 001 结论:`JAVA_HOME` 跨进程不一致且仅一种 cmd 内联注入形式有效):不在脚本里猜环境变量,改由 `maven-enforcer-plugin` 在 `validate` 阶段硬失败,JDK 17 下构建无法静默通过。 + +## 版本确认 + +| 项 | 实测确认值 | 方式 | +| --- | --- | --- | +| Java | 21.0.12.1(Temurin,runtime `E:\work\jdk-21-temurin`) | `mvnw.cmd -v` 输出 | +| Maven | Apache Maven 3.9.9(8e8579a9e76f7d015ee5ec7bfcdc97d260186937) | `mvnw.cmd -v` 输出 | +| Maven Wrapper 插件 | 3.3.4(`wrapperVersion=3.3.4`) | `.mvn/wrapper/maven-wrapper.properties` | +| Spring Boot | 3.5.16(parent + 启动横幅 `:: Spring Boot :: (v3.5.16)`) | pom + 测试/运行日志 | +| 内嵌容器 | Tomcat 10.1.55 | 运行 jar 日志 | +| 测试框架 | spring-boot-starter-test(JUnit Jupiter,由 Boot BOM 管理,未显式声明版本) | pom | +| Enforcer | maven-enforcer-plugin 3.6.3 | 构建日志 `enforcer:3.6.3:enforce` | +| 构建 jar | `target/qlinker-server-0.0.1-SNAPSHOT.jar`(23,765,432 字节,已 repackage) | `ls -la target/*.jar` | + +`mvnw.cmd` 的 Maven home 解析到 `C:\Users\21616\.m2\wrapper\dists\apache-maven-3.9.9\8e740011...`,未使用 `E:\work\maven-3.9.9`,证明不依赖机器 PATH。构建日志显示依赖从 `https://repo.maven.apache.org/maven2/` 拉取(本机 `~/.m2/settings.xml` 不存在),即未依赖任务 001 记录的 `E:\work\maven-3.9.9\conf\settings.xml`(`D:/maven/repository` + aliyun `mirrorOf=*`)这一机器私有配置。 + +## 实际验证命令及结果 + +工作目录均为 `F:/code/xiaowang/QLinker`。以下命令形式为实际执行形式(cmd 内联 `set JAVA_HOME=...&&` 为任务 001 核实过的唯一可靠注入方式)。 + +| # | 命令 | 结果 | 判定 | +| --- | --- | --- | --- | +| 1 | `git status --short --branch`(开始前) | `## master...origin/master [gone]`,无变更行 | 工作区干净 | +| 2 | `git log --oneline -3` | HEAD = `1fbc2cc docs: accept environment baseline and queue backend skeleton` | 基线确认 | +| 3 | `ls E:/work` | 存在 `jdk-17-temurin`、`jdk-21-temurin`、`maven-3.9.9` | JDK 17 负向检查前置条件满足 | +| 4 | `cmd //c "set JAVA_HOME=E:\work\jdk-21-temurin&& E:\work\maven-3.9.9\bin\mvn.cmd -N -B org.apache.maven.plugins:maven-wrapper-plugin:3.3.4:wrapper -Dmaven=3.9.9"` | BUILD SUCCESS;`Configuring .mvn/wrapper/maven-wrapper.properties to use Maven 3.9.9` | Wrapper 生成成功 | +| 5 | `cmd //c "set JAVA_HOME=E:\work\jdk-21-temurin&& mvnw.cmd -v"` | `Apache Maven 3.9.9`;`Java version: 21.0.12.1`;Maven home 为 `~\.m2\wrapper\dists\apache-maven-3.9.9\8e740011...` | **验收 1 前半通过** | +| 6 | `cmd //c "set JAVA_HOME=E:\work\jdk-17-temurin&& mvnw.cmd -B validate"` | **BUILD FAILURE**(`PIPESTATUS[0]=1`);`enforcer:3.6.3:enforce` → `Rule 0: RequireJavaVersion failed`,消息「QLinker 要求使用 JDK 21 构建,请使用 JDK 21 入口执行构建。」;`Rule 1: RequireMavenVersion passed` | **验收 1 后半通过**(明确失败,非静默通过) | +| 7 | `cmd //c "set JAVA_HOME=E:\work\jdk-21-temurin&& mvnw.cmd -B test"` | BUILD SUCCESS;`Tests run: 2, Failures: 0, Errors: 0, Skipped: 0`(`HealthEndpointTests` 1 项、`QLinkerApplicationTests` 1 项);`Started QLinkerApplicationTests using Java 21.0.12.1`;Total time 38.666 s | **验收 2 通过** | +| 8 | `cmd //c "set JAVA_HOME=E:\work\jdk-21-temurin&& mvnw.cmd -B package"` | BUILD SUCCESS;`Replacing main artifact ... with repackaged archive`;产出 `target/qlinker-server-0.0.1-SNAPSHOT.jar`(23,765,432 B);Total time 02:41 min | **验收 3 通过** | +| 9 | `E:/work/jdk-21-temurin/bin/java.exe -jar target/qlinker-server-0.0.1-SNAPSHOT.jar --server.port=18080`(后台) | `Started QLinkerApplication in 2.356 seconds`,Tomcat 18080,`Exposing 1 endpoint beneath base path '/actuator'` | 默认配置可启动(未提供任何 MySQL/MinIO/NapCat 配置) | +| 10 | `curl -s -w "%{http_code}" http://127.0.0.1:18080/actuator/health` | `HTTP=200`,body `{"status":"UP"}` | **验收 4 前半通过** | +| 11 | `cmd //c "taskkill /PID 16844 /F"` 后再次 `curl` | `成功: 已终止 PID 为 16844 的进程。`;`HTTP=000`、curl exit 7(连接被拒) | 进程已停止 | +| 12 | `cmd //c "set JAVA_HOME=E:\work\jdk-21-temurin&& mvnw.cmd -B clean"` | BUILD SUCCESS;`target/` 已不存在 | **验收 4 后半:临时产物已清理** | +| 13 | `git status --short --branch` + `git diff --stat` + `git status --porcelain -uall`(结束时) | 见下节「工作区状态」 | 范围核对 | + +默认端口与健康端点说明:`application.yml` 设 `server.port=8080`,健康端点为 `GET /actuator/health`;`management.endpoints.web.exposure.include=health`、`management.endpoint.health.show-details=never`(不暴露依赖明细,避免后续接入组件时泄露内部信息)。#9/#10 用 `--server.port=18080` 覆盖仅为避免与本机其他服务端口冲突,不改变默认配置。 + +### 工作区状态(结束时) + +``` +## master...origin/master [gone] + M .gitignore +?? .mvn/wrapper/maven-wrapper.properties +?? mvnw +?? mvnw.cmd +?? pom.xml +?? src/main/java/com/qlinker/QLinkerApplication.java +?? src/main/resources/application.yml +?? src/test/java/com/qlinker/HealthEndpointTests.java +?? src/test/java/com/qlinker/QLinkerApplicationTests.java +``` + +`git diff --stat`:`.gitignore | 3 +++`。无暂存内容,未提交、未推送。任务开始时的既有未跟踪/忽略文件(`env-local.md`、`local/`、`.idea/`、`.gitnexus/`、`.classpath`、`.project`、`.settings/`)均原样保留,未删除、未覆盖。 + +## 未执行验证 + +- MySQL / MinIO / NapCat 相关的任何连接、认证、迁移、收发验证:**未执行**(任务单明确排除,骨架未引入相关依赖,也不存在对应代码)。 +- Flyway 迁移、数据库表结构、资源初始化:**未执行**(P0-02 不引入 Flyway/驱动)。 +- 前端构建与页面测试:**未执行**(P0-02 不含前端)。 +- 真实环境 NapCat 版本兼容验证、`docs/能力基线.json` 门禁回归:**未执行**(不属本任务范围)。 +- Linux 环境构建验证:**未执行**,本次全部在 Windows 10 + Git Bash/cmd 上执行。正式部署目标为 Linux,跨平台构建需在部署任务补验。 +- 系统级软件安装、PATH/机器级或用户级 `JAVA_HOME` 修改、Git 提交/推送:**未执行**(任务边界禁止)。 +- 集成测试(Testcontainers / 真实中间件):**未执行**,本机无 Docker,首期骨架仅上下文测试 + MockMvc 健康端点测试。 + +## 未解决问题 / 风险 + +1. **`distributionUrl` 由 aliyun 镜像改为 Maven Central**:Wrapper 插件按当前生效的 Maven `settings.xml` 镜像生成 URL(初次生成为 `https://maven.aliyun.com/repository/public/...`),已手工改为 `https://repo.maven.apache.org/maven2/...` 以保证跨机器可复现。风险:内网/离线环境若只能走镜像,需要另行提供受控 `settings.xml`;本机 `~/.m2/wrapper/dists` 已缓存 3.9.9,首次构建几乎零下载。 +2. **`JAVA_HOME` 三态并存仍未根治**:Git Bash 进程内 21(IDE 注入)、新起 `cmd` 子进程 17。本任务用 enforcer 硬失败兜底(#6 已证明 JDK 17 下 `validate` 必然失败),但**构建脚本层面仍需使用那条唯一可靠的 cmd 内联注入形式**。是否将用户级 `JAVA_HOME` 改为 21 属系统级变更,本任务未动,建议由用户决定。 +3. **本地仓库与镜像仍属机器私有配置**:`E:\work\maven-3.9.9\conf\settings.xml` 设 `localRepository=D:/maven/repository` + aliyun `mirrorOf=*`。Wrapper 路径不受其影响(走 `~/.m2/repository` + Central),但直接用绝对路径调用 `E:\work\maven-3.9.9\bin\mvn.cmd` 时仍会生效,两条路径的解析结果可能不一致。建议后续任务在项目内提供受控 `settings.xml`。 +4. **enforcer 的 `requireMavenVersion` 只在 `validate` 之后生效**:`mvnw.cmd -v` 不做校验,仅版本自述;绕过 Wrapper 用旧 Maven 时,`validate` 阶段才会拦。当前约束为 `[3.9.9,4.0.0)`,若后续需允许 Maven 4 需显式调整。 +5. **`HealthEndpointTests` 走 MockMvc,未覆盖真实网络端口**;真实 HTTP 200 由 #10 的 `curl` 独立证明。两者结合才构成验收 4 的完整证据,单独任一项不足。 +6. **`.classpath`/`.project`/`.settings/` 来源未完全定性**:时间戳与 Wrapper 生成时刻接近,`.project` 内含 `__CREATED_BY_JAVA_LANGUAGE_SERVER__` 过滤器,倾向为 IDE Java 语言服务器写入。本任务只加忽略项、未删除,若用户确认需要入库可回退该 3 行 `.gitignore` 变更。 +7. **`origin/master [gone]`**:远端跟踪分支不存在。本任务未触碰远端;后续推送需先确认远端分支状态。 +8. **Spring Boot 3.5.16 为保守线而非最新主版本**(Central GA 已到 4.1.2)。本次验证证明 3.5.16 可构建可运行可测试,未评估 4.x 迁移成本;如需切换须按 `docs/LLMChangeMemory/版本基线.md` 另开兼容性任务。 + +## 与任务范围的偏差 + +- 额外新增 `.gitignore` 3 行工程忽略项:任务单「范围」允许「如果需要 `.gitignore`,只增加工程相关忽略项」,属允许范围内。 +- 额外执行 `mvnw.cmd -B clean` 清理 `target/`:验收 4 要求「停止进程后清理临时产物」,故执行。 +- `mvnw.cmd -v` 与 `-B test`/`-B package` 均在 `F:/code/xiaowang/QLinker` 目录内以 `mvnw.cmd` 调用,未依赖 PATH;`-v` 输出为 `Apache Maven 3.9.9`,满足验收 1。 +- 生成 Wrapper 时借用本机 `E:\work\maven-3.9.9\bin\mvn.cmd` 一次性执行 `maven-wrapper-plugin:3.3.4:wrapper`(Wrapper 尚不存在,无其他途径);此后所有构建验证均只走 `mvnw.cmd`。 +- 未修改 `docs/LLMChangeMemory/任务索引.md`、`docs/LLMChangeMemory/版本基线.md` 及其他文档基线(按任务单「不改用户已有文档基线」与 AGENTS.md 26 章验收归属)。 +- 无提交、无推送、无系统级安装、无环境变量修改、未输出任何凭据或连接串秘密字段。 diff --git a/docs/LLMChangeMemory/任务-003-Flyway迁移文件与数据库基线.md b/docs/LLMChangeMemory/任务-003-Flyway迁移文件与数据库基线.md new file mode 100644 index 0000000..cac858e --- /dev/null +++ b/docs/LLMChangeMemory/任务-003-Flyway迁移文件与数据库基线.md @@ -0,0 +1,40 @@ +# 任务 003:Flyway 迁移文件与数据库基线 + +目标:把数据库设计中的首期核心表转成可追踪、可审查的 Flyway 迁移文件,并锁定依赖版本;本任务不连接真实数据库。 + +做法:在现有单 Maven 工程中加入 Flyway 11.7.2、`flyway-mysql` 和 MySQL Connector/J 9.7.0 依赖;按数据库设计第 20 章的顺序建立核心迁移脚本,至少覆盖实例/系统配置、身份权限、NapCat 绑定、原始事件/去重/处理日志、归一化消息/消息段;保留未知事件和会话类型 + 会话 ID 的去重约束。只做离线结构审查和构建验证,不对共享 MySQL 执行建库、迁移、删除或清理。 + +参考:`docs/数据库设计.md` 第 2、4、5、6、7、8、20、22 章;`docs/决策基线.md` 的 DEC-001/002/003、GC-005、GC-010;`docs/LLMChangeMemory/版本基线.md`。 + +## 范围 + +- 在 `pom.xml` 增加 `flyway-core`、`flyway-mysql`、`mysql-connector-j`,版本使用当前基线/BOM,不引入其他数据库或 Docker 依赖。 +- 新增 `src/main/resources/db/migration/` 下有序的 `V*.sql` 文件。建议按 V1 实例与系统配置、V2 身份权限、V3 NapCat、V4 原始事件与去重、V5 归一化消息与消息段拆分;实际拆分必须在交付文档列出。 +- 表名、字段类型、非空语义、主键、唯一约束、索引、公共时间字段和删除策略以数据库设计为准;不凭空新增业务字段。 +- SQL 中不得写入真实账号、密码、令牌、IP 凭据或样本正文。 +- 增加离线可复核的迁移文件检查(可用简短脚本或测试),至少验证版本顺序、文件存在和禁止重复版本;不把静态文件存在误报为真实数据库执行成功。 +- 保持当前应用在无数据库配置时可启动;若新增依赖触发自动配置,使用测试/默认配置明确隔离,不能偷偷连接共享数据库。 + +## 不做 + +- 不连接 `192.168.5.15` MySQL,不读取或要求用户提供凭据。 +- 不执行 `CREATE DATABASE`、`DROP`、`clean`、真实 Flyway migrate/repair/clean 或任何不可逆数据库操作。 +- 不实现 DAO、消息接收、NapCat 连接、资源初始化、权限接口或前端。 +- 不修改正式数据库设计文档的业务语义;发现设计缺口写入交付文档,先停在报告。 +- 不提交或推送,不修改全局环境。 + +## 验收标准 + +1. `mvnw.cmd -B test` 在 JDK 21 入口下成功,现有 2 个测试仍通过;应用默认启动不得要求数据库凭据。 +2. `mvnw.cmd -B dependency:tree` 能看到 Flyway Core、`flyway-mysql` 和 MySQL Connector/J,版本与基线一致。 +3. 迁移文件按版本严格递增、无重复版本,命名符合 `V__.sql`;离线检查实际通过。 +4. 迁移覆盖范围、字段/索引依据和与数据库设计的差异在交付文档中逐项列出;未知结构保留和去重键约束不能被省略。 +5. 交付文档明确写出未执行真实数据库迁移,并列出后续真实 MySQL 验证所需的安全前置条件。 + +## 交付文件 + +`docs/LLMChangeMemory/任务-003-交付文档.md` + +## 约束 + +先读取 `AGENTS.md` 和本任务单;保留当前未提交的 P0-02 工程骨架;只修改任务范围和指定交付文档;不输出凭据;不提交/推送。 diff --git a/docs/LLMChangeMemory/任务-003-交付文档.md b/docs/LLMChangeMemory/任务-003-交付文档.md new file mode 100644 index 0000000..89e5fe4 --- /dev/null +++ b/docs/LLMChangeMemory/任务-003-交付文档.md @@ -0,0 +1,19 @@ +# 任务 003 交付文档 + +状态:待执行代理补交 + +变更文件: + +实现摘要: + +依赖版本与迁移清单: + +离线检查结果: + +实际验证命令及结果: + +未执行验证: + +未解决问题 / 风险: + +与任务范围的偏差: diff --git a/docs/LLMChangeMemory/任务索引.md b/docs/LLMChangeMemory/任务索引.md index 4a96728..c3d774e 100644 --- a/docs/LLMChangeMemory/任务索引.md +++ b/docs/LLMChangeMemory/任务索引.md @@ -3,4 +3,5 @@ | ID | 任务 | 状态 | 任务单 | 交付文档 | 主代理结论 | | --- | --- | --- | --- | --- | --- | | 001 | 环境与工程基线核查 | 已验收 | [任务单](任务-001-环境与工程基线核查.md) | [交付文档](任务-001-交付文档.md) | 只读核查完整;NapCat 门禁 PASS;构建入口和 Spring Boot 版本仍由 002 落地 | -| 002 | 构建基线与最小后端骨架 | 待派发 | [任务单](任务-002-构建基线与最小后端骨架.md) | [交付文档](任务-002-交付文档.md) | 暂定 Java 21 / Maven 3.9.9 Wrapper / Spring Boot 3.5.16 | +| 002 | 构建基线与最小后端骨架 | 已验收 | [任务单](任务-002-构建基线与最小后端骨架.md) | [交付文档](任务-002-交付文档.md) | Wrapper/JDK 门禁/测试/打包/真实健康检查均通过 | +| 003 | Flyway 迁移文件与数据库基线 | 待派发 | [任务单](任务-003-Flyway迁移文件与数据库基线.md) | [交付文档](任务-003-交付文档.md) | 先离线建立核心表迁移;不连接真实数据库、不执行破坏性操作 | diff --git a/docs/LLMChangeMemory/版本基线.md b/docs/LLMChangeMemory/版本基线.md index 0eff683..79287f0 100644 --- a/docs/LLMChangeMemory/版本基线.md +++ b/docs/LLMChangeMemory/版本基线.md @@ -1,6 +1,6 @@ # 首期技术版本基线 -状态:P0-02 执行基线,待构建骨架验收后转为已锁定 +状态:P0-02 已验收;构建基线已锁定,后续依赖按任务逐项补充 Spring Boot 选 3.5.16 是有意采用保守稳定线,而非追随最新主版本。2026-11-02 检查 Maven Central 元数据时,4.1.2 已发布、4.2.0-RC1 为预发布;本项目尚无代码或第三方集成验证,首个骨架优先选择已在本机缓存且任务 001 核查过的 3.5.16。后续如改用 4.x,需另开兼容性任务并同步版本基线。 @@ -8,8 +8,8 @@ Spring Boot 选 3.5.16 是有意采用保守稳定线,而非追随最新主版 | --- | --- | --- | | Java | 21 | 已由 DEC-001 确认 | | Maven | 3.9.9 | 通过 Maven Wrapper 固定;不依赖 PATH;Wrapper 插件固定 3.3.4 | -| Spring Boot | 3.5.16 | 采用任务 001 的保守建议;P0-02 验收时确认可构建 | -| 数据库迁移 | P0-02 不引入;P0-03 再锁定 Flyway | 避免空骨架阶段绑定数据库实现 | +| Spring Boot | 3.5.16 | P0-02 已确认可构建、测试、打包和启动 | +| 数据库迁移 | Flyway 11.7.2 + `flyway-mysql` | P0-03 引入并按数据库设计生成核心迁移;真实库验证另行排期 | | MySQL 驱动 / MinIO SDK | P0-02 不引入 | 在数据库和资源初始化任务中按实际接口锁定 | | 前端 | P0-02 不实现 | P7 前单独锁定 Vue/Node/Vite | | 测试 | Spring Boot Test + JUnit Jupiter(由 Boot BOM 管理) | P0-02 只验证应用上下文和健康端点 | diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..bd8896b --- /dev/null +++ b/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..92450f9 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..19428ad --- /dev/null +++ b/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.5.16 + + + + com.qlinker + qlinker-server + 0.0.1-SNAPSHOT + qlinker-server + QLinker 后端服务 + + + 21 + 21 + 3.6.3 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce-java-version + validate + + enforce + + + + + [21,) + QLinker 要求使用 JDK 21 构建,请使用 JDK 21 入口执行构建。 + + + [3.9.9,4.0.0) + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/com/qlinker/QLinkerApplication.java b/src/main/java/com/qlinker/QLinkerApplication.java new file mode 100644 index 0000000..cbac34a --- /dev/null +++ b/src/main/java/com/qlinker/QLinkerApplication.java @@ -0,0 +1,12 @@ +package com.qlinker; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class QLinkerApplication { + + public static void main(String[] args) { + SpringApplication.run(QLinkerApplication.class, args); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..e9e9436 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,15 @@ +server: + port: 8080 + +spring: + application: + name: qlinker-server + +management: + endpoints: + web: + exposure: + include: health + endpoint: + health: + show-details: never diff --git a/src/test/java/com/qlinker/HealthEndpointTests.java b/src/test/java/com/qlinker/HealthEndpointTests.java new file mode 100644 index 0000000..548765f --- /dev/null +++ b/src/test/java/com/qlinker/HealthEndpointTests.java @@ -0,0 +1,26 @@ +package com.qlinker; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.web.servlet.MockMvc; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest +@AutoConfigureMockMvc +class HealthEndpointTests { + + @Autowired + private MockMvc mockMvc; + + @Test + void actuatorHealthReturnsUp() throws Exception { + mockMvc.perform(get("/actuator/health")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("UP")); + } +} diff --git a/src/test/java/com/qlinker/QLinkerApplicationTests.java b/src/test/java/com/qlinker/QLinkerApplicationTests.java new file mode 100644 index 0000000..7f3764a --- /dev/null +++ b/src/test/java/com/qlinker/QLinkerApplicationTests.java @@ -0,0 +1,12 @@ +package com.qlinker; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class QLinkerApplicationTests { + + @Test + void contextLoads() { + } +}