youfool-prj-springboot3-tem.../README.md

124 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# youfool-prj-springboot3-template
基于 Spring Boot 3.x 的企业级后端项目模板。
## 项目简介
本模板是 youfool 框架团队提供的基础后台开发模板,集成了常用的企业级开发组件和最佳实践,帮助开发者快速搭建业务系统。
## 技术栈
| 组件 | 版本 | 说明 |
|------|------|------|
| Spring Boot | 3.4.5 | 基础框架 |
| Java | 21 | 编程语言 |
| PostgreSQL | 42.7.9 | 主数据库 |
| MySQL | 8.0.28 | 数据库驱动 |
| Lombok | 1.18.42 | 简化代码 |
| youfool-framework-springboot3 | 1.0.4 | 基础框架 |
## 核心特性
- **多数据源支持**:集成动态数据源,支持主从配置
- **权限认证**:集成 Sa-Token支持灵活的权限控制
- **API 文档**:集成 Knife4j提供在线接口文档
- **监控面板**:集成 Druid 数据库连接池监控
- **CMS 后台**:内置基础框架 CMS 后台管理系统
## 快速开始
### 环境要求
- JDK 21+
- Maven 3.6+
- PostgreSQL 或 MySQL 数据库
### 运行项目
```bash
# 编译打包
mvn clean package
# 运行项目
java -jar target/youfool-prj-springboot3-template.jar
# 或指定环境运行
java -jar target/youfool-prj-springboot3-template.jar --spring.profiles.active=dev
```
### 访问地址
| 功能 | 路径 | 账号 | 密码 |
|------|------|------|------|
| CMS 后台管理系统 | /cms | admin | 123456 |
| 接口文档 | /doc.html | admin | 123456 |
| Druid 监控 | /druid | admin | 123456 |
> 注意:接口文档如出现乱码,请在启动时指定 JVM 参数 `-Dfile.encoding=UTF-8`
## 配置说明
### 环境配置
项目支持多环境配置,通过 `spring.profiles.active` 切换:
- `dev` - 开发环境
- `prod` - 生产环境
### 数据源配置
当前版本使用苍米豆的 [动态数据源](https://github.com/baomidou/dynamic-datasource-spring-boot-starter)。
**重要提示**:使用事务时需使用 `@DSTransactional` 代替 `@Transactional` 注解。
### 端口配置
默认端口为 8080可通过环境变量 `PRJ_PORT` 修改。
## 项目结构
```
youfool-prj-springboot3-template/
├── src/
│ ├── main/
│ │ ├── java/com/chinaweal/youfool/prj/
│ │ │ ├── YoufoolApplication.java # 启动类
│ │ │ ├── common/ # 公共模块
│ │ │ ├── config/ # 配置类
│ │ │ ├── controller/ # 控制器
│ │ │ ├── service/ # 业务逻辑
│ │ │ └── dev/ # 开发工具(代码生成等)
│ │ └── resources/
│ │ ├── application.yml # 主配置
│ │ ├── application-dev.yml # 开发环境配置
│ │ ├── application-prod.yml # 生产环境配置
│ │ └── logback-spring.xml # 日志配置
└── pom.xml # Maven 配置
```
## 常用命令
```bash
# 清理并编译
mvn clean compile
# 运行测试
mvn test
# 打包(跳过测试)
mvn clean package -DskipTests
# 代码风格检查
mvn checkstyle:check
```
## 注意事项
1. 本项目使用 JDK 21 编译,请确保本地 JDK 版本匹配
2. 动态数据源事务必须使用 `@DSTransactional` 注解
3. 生产环境部署时请修改默认账号密码
4. 建议配置独立的 youfool 数据源用于存储 restLog
## 许可证
Copyright © chinaweal.com.cn