Merge remote-tracking branch 'gitee/master'
# Conflicts: # pom.xml # src/main/resources/application-prod.yml
This commit is contained in:
commit
1a239fcc15
9 files changed
+83
-101
No files matched your search
+4
-5
@@ -2,9 +2,9 @@
|
||||
|
||||
# <img alt="youlai-boot" width="40" height="40" valign="middle" src="./docs/images/logo/logo.png"> 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**
|
||||
|
||||
[](https://spring.io/projects/spring-boot)
|
||||
[](https://spring.io/projects/spring-boot)
|
||||
[](https://openjdk.org/)
|
||||
[](LICENSE)
|
||||
[](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 <http://localhost:8000/doc.html> (apidoc) or <http://localhost:8000/swagger-ui.html> (Swagger UI). If the API docs open, the backend is running properly.
|
||||
Once started, visit <http://localhost:8000/doc.html> (apishow) or <http://localhost:8000/swagger-ui.html> (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 <http://localhost:3000>, 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
|
||||
```
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
# <img alt="youlai-boot" width="40" height="40" src="./docs/images/logo/logo.png" valign="middle"> youlai-boot
|
||||
|
||||
**Java 17 + Spring Boot 4.1.2 企业级权限管理系统后端**
|
||||
**Java 17 + Spring Boot 4.2.0 企业级权限管理系统后端**
|
||||
|
||||
[](https://spring.io/projects/spring-boot)
|
||||
[](https://spring.io/projects/spring-boot)
|
||||
[](https://openjdk.org/)
|
||||
[](LICENSE)
|
||||
[](https://gitee.com/youlaiorg/youlai-boot/stargazers)
|
||||
@@ -20,6 +20,7 @@
|
||||
[](https://admin.youlai.tech)
|
||||
[](https://app.youlai.tech)
|
||||
[](https://www.youlai.tech/docs/server/spring-boot/)
|
||||
[](https://api.youlai.tech/doc.html)
|
||||
[](./README.en.md)
|
||||
|
||||
</div>
|
||||
@@ -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
|
||||
```
|
||||
|
||||
启动后访问 <http://localhost:8000/doc.html>(apidoc)或 <http://localhost:8000/swagger-ui.html>(Swagger UI),能打开接口文档即说明后端已正常运行。
|
||||
启动后访问 <http://localhost:8000/doc.html>(apishow)或 <http://localhost:8000/swagger-ui.html>(Swagger UI),能打开接口文档即说明后端已正常运行。
|
||||
|
||||
5. 启动前端(可选):
|
||||
如需可视化操作界面,启动配套前端 [vue3-element-admin](https://gitee.com/youlaiorg/vue3-element-admin),访问 <http://localhost:3000>,使用 `admin` / `123456` 登录。
|
||||
@@ -161,7 +162,6 @@ youlai-boot/
|
||||
│ │ ├── sms/ # 短信服务
|
||||
│ │ └── realtime/ # WebSocket 实时通信
|
||||
│ └── system/ # 系统业务(用户/角色/菜单/部门/字典等)
|
||||
├── docker-compose.yml # 中间件一键编排(MySQL/Redis/RustFS/Xxl-Job)
|
||||
└── pom.xml # Maven 依赖管理
|
||||
```
|
||||
|
||||
|
||||
@@ -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:
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
<groupId>com.youlai</groupId>
|
||||
<artifactId>youlai-boot</artifactId>
|
||||
<version>4.15.0</version>
|
||||
<version>4.15.1</version>
|
||||
<description>基于 Java 17 + SpringBoot 4 + Spring Security 构建的权限管理系统。</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.2</version> <!-- lookup parent from repository -->
|
||||
<version>4.2.0</version> <!-- lookup parent from repository -->
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -66,18 +66,21 @@
|
||||
<!-- 架构约束测试 -->
|
||||
<archunit.version>1.3.0</archunit.version>
|
||||
|
||||
<weixin-java-miniapp.version>4.8.1.B</weixin-java-miniapp.version>
|
||||
<weixin-java-miniapp.version>4.8.6.B</weixin-java-miniapp.version>
|
||||
|
||||
<!-- Eclipse Paho MQTT 客户端版本 -->
|
||||
<paho-client.version>1.2.5</paho-client.version>
|
||||
|
||||
<spring-ai.version>2.0.2</spring-ai.version>
|
||||
<!-- 加密库统一版本:微信 SDK 与阿里云 SDK 要求的版本不同,混用会在运行时报错 -->
|
||||
<bouncycastle.version>1.84</bouncycastle.version>
|
||||
|
||||
<!-- springdoc 3.x 调用 Schema.$dynamicRef(),旧版本注解包没有该方法 -->
|
||||
<spring-ai.version>2.1.0</spring-ai.version>
|
||||
|
||||
<!-- 接口文档页依赖该版本,低于它时页面会加载失败 -->
|
||||
<swagger.version>2.2.55</swagger.version>
|
||||
|
||||
<!-- apidoc 接口文档 UI -->
|
||||
<apidoc.version>0.3.1</apidoc.version>
|
||||
<!-- apishow 接口文档 UI -->
|
||||
<apishow.version>0.4.0</apishow.version>
|
||||
|
||||
</properties>
|
||||
|
||||
@@ -90,7 +93,7 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- openai-java 传递的是 2.2.31,与 springdoc 3.1.1 的 2.2.55 冲突 -->
|
||||
<!-- Spring AI 会带进更低版本,这里统一压回上面指定的版本,否则文档页加载失败 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
@@ -101,6 +104,12 @@
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<!-- 固定用上面的版本,避免被其它依赖替换成不兼容的版本 -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk18on</artifactId>
|
||||
<version>${bouncycastle.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
@@ -317,11 +326,11 @@
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- apidoc 接口文档 UI,读取 /v3/api-docs 渲染文档页面 -->
|
||||
<!-- apishow 接口文档 UI,读取 /v3/api-docs 渲染文档页面 -->
|
||||
<dependency>
|
||||
<groupId>tech.youlai</groupId>
|
||||
<artifactId>apidoc-spring-boot-starter</artifactId>
|
||||
<version>${apidoc.version}</version>
|
||||
<artifactId>apishow-spring-boot-starter</artifactId>
|
||||
<version>${apishow.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MapStruct 对象映射 -->
|
||||
|
||||
@@ -304,9 +304,9 @@ captcha:
|
||||
expire-seconds: 120
|
||||
|
||||
# 接口文档 UI
|
||||
apidoc:
|
||||
apishow:
|
||||
enabled: true # 启用文档页面与静态资源
|
||||
path: /doc.html # 文档入口路径,页面资源固定在 /apidoc/
|
||||
path: /doc.html # 文档入口路径,页面资源固定在 /apishow/
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ captcha:
|
||||
# 验证码有效期(秒)
|
||||
expire-seconds: 120
|
||||
|
||||
apidoc:
|
||||
apishow:
|
||||
enabled: false # 不注册文档入口与静态资源
|
||||
|
||||
---
|
||||
|
||||
@@ -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
|
||||
@@ -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("${"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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) : "";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user