diff --git a/README.en.md b/README.en.md index c8d79f01..2a7a5663 100644 --- a/README.en.md +++ b/README.en.md @@ -2,9 +2,9 @@ # youlai-boot youlai-boot -**Java 17 + Spring Boot 4.1.2 Enterprise-Grade Permission Management Backend** +**Java 17 + Spring Boot 4.2.0 Enterprise-Grade Permission Management Backend** -[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-4.1.2-6DB33F?logo=spring-boot)](https://spring.io/projects/spring-boot) +[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-4.2.0-6DB33F?logo=spring-boot)](https://spring.io/projects/spring-boot) [![JDK](https://img.shields.io/badge/JDK-17%2B-007396?logo=openjdk)](https://openjdk.org/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue?logo=apache)](LICENSE) [![Gitee Star](https://gitee.com/youlaiorg/youlai-boot/badge/star.svg)](https://gitee.com/youlaiorg/youlai-boot/stargazers) @@ -78,7 +78,7 @@ ## Quick Start -**Requirements**: JDK 17+ · MySQL 8.0+ · Redis 6.0+ +**Requirements**: JDK 17+ · MySQL 8.0+ · Redis 6.0+. Middleware can be started with the Compose file from the deployment guide. 1. Clone the project: @@ -131,7 +131,7 @@ mvn spring-boot:run ``` - Once started, visit (apidoc) or (Swagger UI). If the API docs open, the backend is running properly. + Once started, visit (apishow) or (Swagger UI). If the API docs open, the backend is running properly. 5. Start the frontend (optional): For a visual admin UI, start the companion frontend [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin), visit , and log in with `admin` / `123456`. @@ -175,7 +175,6 @@ youlai-boot/ │ │ ├── sms/ # SMS service │ │ └── realtime/ # WebSocket communication │ └── system/ # System business (user/role/menu/dept/dict etc.) -├── docker-compose.yml # One-click middleware orchestration (MySQL/Redis/RustFS/Xxl-Job) └── pom.xml # Maven dependency management ``` diff --git a/README.md b/README.md index 395eb1cc..667f7e2f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ # youlai-boot youlai-boot -**Java 17 + Spring Boot 4.1.2 企业级权限管理系统后端** +**Java 17 + Spring Boot 4.2.0 企业级权限管理系统后端** -[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-4.1.2-6DB33F?logo=spring-boot)](https://spring.io/projects/spring-boot) +[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-4.2.0-6DB33F?logo=spring-boot)](https://spring.io/projects/spring-boot) [![JDK](https://img.shields.io/badge/JDK-17%2B-007396?logo=openjdk)](https://openjdk.org/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue?logo=apache)](LICENSE) [![Gitee Star](https://gitee.com/youlaiorg/youlai-boot/badge/star.svg)](https://gitee.com/youlaiorg/youlai-boot/stargazers) @@ -20,6 +20,7 @@ [![在线预览](https://img.shields.io/badge/在线预览-2D8CF0?style=for-the-badge\&logo=google-chrome\&logoColor=white)](https://admin.youlai.tech) [![移动端预览](https://img.shields.io/badge/移动端预览-19BE6B?style=for-the-badge\&logo=android\&logoColor=white)](https://app.youlai.tech) [![阅读文档](https://img.shields.io/badge/阅读文档-8B5CF6?style=for-the-badge\&logo=gitbook\&logoColor=white)](https://www.youlai.tech/docs/server/spring-boot/) +[![在线接口文档](https://img.shields.io/badge/在线接口文档-13C2C2?style=for-the-badge\&logo=swagger\&logoColor=white)](https://api.youlai.tech/doc.html) [![English](https://img.shields.io/badge/English-00B4D8?style=for-the-badge\&logo=google-translate\&logoColor=white)](./README.en.md) @@ -78,7 +79,7 @@ ## 快速开始 -**环境要求**:JDK 17+ · MySQL 8.0+ · Redis 6.0+ +**环境要求**:JDK 17+ · MySQL 8.0+ · Redis 6.0+。中间件可用[部署运维](https://www.youlai.tech/docs/server/spring-boot/deploy.html)里的 compose 编排一键启动。 1. 克隆项目: @@ -115,7 +116,7 @@ mvn spring-boot:run ``` - 启动后访问 (apidoc)或 (Swagger UI),能打开接口文档即说明后端已正常运行。 + 启动后访问 (apishow)或 (Swagger UI),能打开接口文档即说明后端已正常运行。 5. 启动前端(可选): 如需可视化操作界面,启动配套前端 [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin),访问 ,使用 `admin` / `123456` 登录。 @@ -161,7 +162,6 @@ youlai-boot/ │ │ ├── sms/ # 短信服务 │ │ └── realtime/ # WebSocket 实时通信 │ └── system/ # 系统业务(用户/角色/菜单/部门/字典等) -├── docker-compose.yml # 中间件一键编排(MySQL/Redis/RustFS/Xxl-Job) └── pom.xml # Maven 依赖管理 ``` diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 82d78484..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Docker Compose 一键安装中间件 MySQL、Redis、RustFS、Xxl-Job -# -# 安装:docker compose up -d -# 卸载:docker compose down(加 -v 同时删除数据卷) -# -# 说明: -# - name 固定项目名,容器统一管理和卸载,避免与其他项目冲突 -# - 中间件配置全部内联于 command 参数,无需外部配置文件 -# - 数据持久化使用命名卷(docker volume 统一管理),不污染项目目录 -# - 对象存储使用 RustFS(S3 协议兼容) - -name: youlai-boot - -services: - mysql: - image: mysql:8.0.29 - container_name: mysql - restart: unless-stopped - # 等价于原 my.cnf 的 utf8mb4 字符集设置(MySQL 8 其余项与默认值一致) - command: --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_ai_ci - environment: - - TZ=Asia/Shanghai - - LANG=en_US.UTF-8 - - MYSQL_ROOT_PASSWORD=123456 - volumes: - - youlai-mysql-data:/var/lib/mysql - ports: - - 3306:3306 - - redis: - image: redis:7.2.3 - container_name: redis - restart: unless-stopped - # --protected-mode no 允许远程连接(原 redis.conf 唯一非默认项) - command: redis-server --requirepass 123456 --appendonly no --protected-mode no - environment: - - TZ=Asia/Shanghai - volumes: - - youlai-redis-data:/data - ports: - - 6379:6379 - - rustfs: - image: rustfs/rustfs:latest - container_name: rustfs - restart: unless-stopped - environment: - - TZ=Asia/Shanghai - - LANG=en_US.UTF-8 - - RUSTFS_ACCESS_KEY=rustfs-admin - - RUSTFS_SECRET_KEY=rustfs-admin - volumes: - - youlai-rustfs-data:/data - ports: - - 9000:9000 - - 9001:9001 - - xxl-job-admin: - image: xuxueli/xxl-job-admin:3.4.2 - container_name: xxl-job-admin - restart: unless-stopped - environment: - PARAMS: '--spring.datasource.url=jdbc:mysql://mysql:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=root --spring.datasource.password=123456 --spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver' - volumes: - - youlai-xxljob-logs:/data/applogs - ports: - - 8080:8080 - -volumes: - youlai-mysql-data: - youlai-redis-data: - youlai-rustfs-data: - youlai-xxljob-logs: diff --git a/pom.xml b/pom.xml index 0b7d37b9..96910609 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ com.youlai youlai-boot - 4.15.0 + 4.15.1 基于 Java 17 + SpringBoot 4 + Spring Security 构建的权限管理系统。 org.springframework.boot spring-boot-starter-parent - 4.1.2 + 4.2.0 @@ -66,18 +66,21 @@ 1.3.0 - 4.8.1.B + 4.8.6.B 1.2.5 - 2.0.2 + + 1.84 - + 2.1.0 + + 2.2.55 - - 0.3.1 + + 0.4.0 @@ -90,7 +93,7 @@ pom import - + io.swagger.core.v3 swagger-annotations @@ -101,6 +104,12 @@ swagger-annotations-jakarta ${swagger.version} + + + org.bouncycastle + bcprov-jdk18on + ${bouncycastle.version} + @@ -317,11 +326,11 @@ ${springdoc.version} - + tech.youlai - apidoc-spring-boot-starter - ${apidoc.version} + apishow-spring-boot-starter + ${apishow.version} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index a7cf3a5e..8396e409 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -304,9 +304,9 @@ captcha: expire-seconds: 120 # 接口文档 UI -apidoc: +apishow: enabled: true # 启用文档页面与静态资源 - path: /doc.html # 文档入口路径,页面资源固定在 /apidoc/ + path: /doc.html # 文档入口路径,页面资源固定在 /apishow/ --- diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a10f0567..cc7e26d3 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -294,7 +294,7 @@ captcha: # 验证码有效期(秒) expire-seconds: 120 -apidoc: +apishow: enabled: false # 不注册文档入口与静态资源 --- diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1cbc9060..c271f44f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -63,8 +63,8 @@ security: - ${springdoc.swagger-ui.path:/swagger-ui.html} # Swagger UI 路径 - /swagger-ui/** - /v3/api-docs/** - - ${apidoc.path:/doc.html} # apidoc 文档入口 - - /apidoc/** # apidoc 静态资源 + - ${apishow.path:/doc.html} # apishow 文档入口 + - /apishow/** # apishow 静态资源 - /webjars/** - /favicon.ico - /error diff --git a/src/test/java/com/youlai/boot/config/ConfigurationDefaultsTest.java b/src/test/java/com/youlai/boot/config/ConfigurationDefaultsTest.java index 7e659b44..7308341a 100644 --- a/src/test/java/com/youlai/boot/config/ConfigurationDefaultsTest.java +++ b/src/test/java/com/youlai/boot/config/ConfigurationDefaultsTest.java @@ -129,14 +129,14 @@ class ConfigurationDefaultsTest { void documentUiIsEnabledOutsideProduction(String profile) { contextRunner(profile).run(context -> { assertThat(context).hasNotFailed(); - assertThat(context.getEnvironment().getProperty("apidoc.enabled", Boolean.class, true)) + assertThat(context.getEnvironment().getProperty("apishow.enabled", Boolean.class, true)) .as("文档 UI 应在生产环境关闭") .isEqualTo(!profile.equals("prod")); var permitAllUrls = Binder.get(context.getEnvironment()) .bindOrCreate("security", SecurityProperties.class).getPermitAllUrls(); assertThat(permitAllUrls) - .contains("/doc.html", "/apidoc/**") + .contains("/doc.html", "/apishow/**") .allSatisfy(url -> assertThat(url).doesNotContain("${")); }); } diff --git a/src/test/java/com/youlai/boot/config/OpenApiDocsTest.java b/src/test/java/com/youlai/boot/config/OpenApiDocsTest.java new file mode 100644 index 00000000..724fce00 --- /dev/null +++ b/src/test/java/com/youlai/boot/config/OpenApiDocsTest.java @@ -0,0 +1,47 @@ +package com.youlai.boot.config; + +import io.swagger.v3.oas.annotations.media.Schema; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.net.URL; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * 文档端点能力测试 + * + * 注解包版本被依赖降级后,编译和其它单测都不会报错,只有打开文档页时才会失败 + * + * @author Ray.Hao + * @since 4.15.0 + */ +class OpenApiDocsTest { + + // 文档页需要这个方法,注解包版本偏低时这里会失败 + @Test + void swaggerAnnotationsProvideDynamicRef() { + assertThat(Schema.class.getMethods()) + .extracting(Method::getName) + .contains("$dynamicRef"); + } + + // 两个包版本必须一致,混用会让文档页加载失败 + @Test + void swaggerAnnotationsVersionMatchesCore() { + String annotations = jarVersion(Schema.class); + String core = jarVersion(io.swagger.v3.core.util.Json.class); + assertThat(annotations).as("swagger-annotations 版本").isNotBlank(); + assertThat(core).as("swagger-core 版本").isNotBlank(); + assertThat(annotations).as("注解包与 core 版本").isEqualTo(core); + } + + private static String jarVersion(Class type) { + URL location = type.getProtectionDomain().getCodeSource().getLocation(); + String fileName = location.getPath().substring(location.getPath().lastIndexOf('/') + 1); + Matcher matcher = Pattern.compile("-(\\d+\\.\\d+\\.\\d+)\\.jar$").matcher(fileName); + return matcher.find() ? matcher.group(1) : ""; + } +}