first commit
This commit is contained in:
230
README.md
Normal file
230
README.md
Normal file
@@ -0,0 +1,230 @@
|
||||
# Lane Carford - Spring Boot 架构模板
|
||||
|
||||
## 📋 项目简介
|
||||
|
||||
这是一个基于 **Spring Boot 3.1.6** 和 **Java 21** 的纯净企业级架构模板,提供了完整的基础设施组件,可以快速开发各种类型的业务应用。
|
||||
|
||||
## 🛠️ 技术栈
|
||||
|
||||
- **Java**: 21 (启用预览功能)
|
||||
- **Spring Boot**: 3.1.6
|
||||
- **Spring Security**: 6.x
|
||||
- **MyBatis-Plus**: 3.5.5
|
||||
- **MySQL**: 8.x
|
||||
- **Swagger**: SpringDoc OpenAPI 2.6.0
|
||||
- **Lombok**: 自动生成样板代码
|
||||
- **Maven**: 项目构建工具
|
||||
|
||||
## 🏗️ 核心功能
|
||||
|
||||
### ✅ 已实现功能
|
||||
|
||||
1. **🛡️ 全局异常处理** - 统一异常处理和错误响应格式
|
||||
2. **📤 统一API响应** - 标准化的API响应格式
|
||||
3. **📊 分页查询支持** - 完整的分页查询封装
|
||||
4. **🔄 Bean转换工具** - 对象转换和属性复制工具
|
||||
5. **📝 日志切面** - 自动记录Controller方法调用日志
|
||||
6. **⚡ 性能监控切面** - 监控方法执行性能
|
||||
7. **🗄️ MyBatis-Plus集成** - 强大的ORM功能
|
||||
8. **📁 文件上传支持** - 文件上传配置和处理
|
||||
9. **🔒 Spring Security集成** - 基础安全配置
|
||||
10. **📚 Swagger API文档** - 自动生成API文档
|
||||
|
||||
### 🏛️ 架构组件
|
||||
|
||||
```
|
||||
src/main/java/com/aida/lanecarford/
|
||||
├── aspect/ # 切面编程
|
||||
│ ├── LoggingAspect.java # 日志切面
|
||||
│ └── PerformanceAspect.java # 性能监控切面
|
||||
├── common/ # 通用组件
|
||||
│ ├── ApiResponse.java # 统一API响应
|
||||
│ └── PageResult.java # 分页结果封装
|
||||
├── config/ # 配置类
|
||||
│ ├── SecurityConfig.java # 安全配置
|
||||
│ ├── SwaggerConfig.java # API文档配置
|
||||
│ └── WebConfig.java # Web配置
|
||||
├── controller/ # 控制器层 (空目录,待扩展)
|
||||
├── dto/ # 数据传输对象 (空目录,待扩展)
|
||||
├── entity/ # 实体类
|
||||
│ └── BaseEntity.java # 基础实体类
|
||||
├── exception/ # 异常处理
|
||||
│ ├── BusinessException.java # 业务异常
|
||||
│ └── GlobalExceptionHandler.java # 全局异常处理器
|
||||
├── mapper/ # 数据访问层
|
||||
│ └── BaseMapper.java # 基础Mapper接口
|
||||
├── security/ # 安全相关 (空目录,待扩展)
|
||||
├── service/ # 业务逻辑层 (空目录,待扩展)
|
||||
└── util/ # 工具类
|
||||
└── BeanUtil.java # Bean转换工具
|
||||
```
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 1. 环境要求
|
||||
|
||||
- Java 21+
|
||||
- Maven 3.6+
|
||||
- MySQL 8.0+
|
||||
|
||||
### 2. 数据库配置
|
||||
|
||||
```sql
|
||||
-- 创建数据库
|
||||
CREATE DATABASE lanecarford CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
### 3. 修改配置
|
||||
|
||||
编辑 `src/main/resources/application.properties`:
|
||||
|
||||
```properties
|
||||
# 数据库配置
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/lanecarford?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=your_username
|
||||
spring.datasource.password=your_password
|
||||
```
|
||||
|
||||
### 4. 运行项目
|
||||
|
||||
```bash
|
||||
# 编译项目
|
||||
mvn clean compile
|
||||
|
||||
# 运行项目
|
||||
mvn spring-boot:run
|
||||
|
||||
# 或者打包后运行
|
||||
mvn clean package
|
||||
java -jar target/lanecarford-0.0.1-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
### 5. 访问应用
|
||||
|
||||
- **应用首页**: http://localhost:8080
|
||||
- **API文档**: http://localhost:8080/swagger-ui.html
|
||||
- **API JSON**: http://localhost:8080/api-docs
|
||||
- **健康检查**: http://localhost:8080/actuator/health
|
||||
|
||||
## 📖 使用指南
|
||||
|
||||
### 创建业务模块
|
||||
|
||||
1. **创建实体类**
|
||||
```java
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("your_table")
|
||||
public class YourEntity extends BaseEntity {
|
||||
private String name;
|
||||
private String description;
|
||||
}
|
||||
```
|
||||
|
||||
2. **创建Mapper接口**
|
||||
```java
|
||||
@Repository
|
||||
public interface YourEntityMapper extends BaseMapper<YourEntity> {
|
||||
// 自定义查询方法
|
||||
}
|
||||
```
|
||||
|
||||
3. **创建Service类**
|
||||
```java
|
||||
@Service
|
||||
public class YourEntityService {
|
||||
@Autowired
|
||||
private YourEntityMapper mapper;
|
||||
|
||||
// 业务逻辑方法
|
||||
}
|
||||
```
|
||||
|
||||
4. **创建Controller类**
|
||||
```java
|
||||
@RestController
|
||||
@RequestMapping("/api/your-entity")
|
||||
@Tag(name = "业务模块", description = "业务相关API")
|
||||
public class YourEntityController {
|
||||
@Autowired
|
||||
private YourEntityService service;
|
||||
|
||||
@Operation(summary = "创建记录")
|
||||
@PostMapping
|
||||
public ApiResponse<YourEntity> create(@Valid @RequestBody CreateRequest request) {
|
||||
YourEntity entity = service.create(request);
|
||||
return ApiResponse.success("创建成功", entity);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 详细功能说明
|
||||
|
||||
请查看 [ARCHITECTURE.md](./ARCHITECTURE.md) 文件,其中包含了所有功能模块的详细说明和使用示例。
|
||||
|
||||
## 🔧 配置说明
|
||||
|
||||
### 主要配置项
|
||||
|
||||
```properties
|
||||
# 应用基础配置
|
||||
spring.application.name=lanecarford-ai-styling-assistant
|
||||
server.port=8080
|
||||
|
||||
# 数据库配置
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/lanecarford
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=123456
|
||||
|
||||
# MyBatis-Plus配置
|
||||
mybatis-plus.configuration.map-underscore-to-camel-case=true
|
||||
mybatis-plus.global-config.db-config.logic-delete-field=deleted
|
||||
|
||||
# 文件上传配置
|
||||
spring.servlet.multipart.max-file-size=10MB
|
||||
spring.servlet.multipart.max-request-size=50MB
|
||||
|
||||
# Swagger配置
|
||||
springdoc.api-docs.path=/api-docs
|
||||
springdoc.swagger-ui.path=/swagger-ui.html
|
||||
```
|
||||
|
||||
## 📁 项目结构
|
||||
|
||||
```
|
||||
lanecarford111/
|
||||
├── src/main/
|
||||
│ ├── java/com/aida/lanecarford/ # Java源码
|
||||
│ └── resources/ # 资源文件
|
||||
│ ├── application.yml # 主配置文件
|
||||
│ └── sql/ # SQL脚本
|
||||
│ ├── schema.sql # 数据库表结构
|
||||
│ └── data.sql # 初始化数据
|
||||
├── uploads/ # 文件上传目录
|
||||
├── pom.xml # Maven配置
|
||||
├── README.md # 项目说明
|
||||
└── ARCHITECTURE.md # 架构功能详细说明
|
||||
```
|
||||
|
||||
## 🤝 贡献指南
|
||||
|
||||
1. Fork 本项目
|
||||
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
||||
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
||||
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
||||
5. 创建 Pull Request
|
||||
|
||||
## 📄 许可证
|
||||
|
||||
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
|
||||
|
||||
## 📞 联系方式
|
||||
|
||||
如有问题或建议,请通过以下方式联系:
|
||||
|
||||
- 项目Issues: [GitHub Issues](https://github.com/your-repo/issues)
|
||||
- 邮箱: your-email@example.com
|
||||
|
||||
---
|
||||
|
||||
**Happy Coding! 🎉**
|
||||
Reference in New Issue
Block a user