# framework **Repository Path**: que/framework ## Basic Information - **Project Name**: framework - **Description**: springcloud、springboot项目脚手架;实现快速搭建,demo见springcloud-test项目 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-23 - **Last Updated**: 2026-04-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 框架脚手架 ## 项目简介 该项目基于 Spring Cloud 及 Spring Boot 的组件基础模板工程(后端),为快速构建项目组件库,子项目通过 Maven 中央仓快速应用相应组件,实现插拔式功能导入; 版本升级,支持了 Spring 6 + Spring Cloud 2023.0.1.2 日志归集配置加入适配 SkyWalking 链路追踪配置。 所有 Maven 工程,依赖脚手架 pom 文件父类;好处: * 1、省略一些重复开发,如权限管理,分库分表,HBase 持久层框架,Redis 持久层等。 * 2、只是依赖不会引进任何 jar,Maven 工程依赖 jar 保持最小单元,去除无关 jar。如:Spring Cloud 应用项目,只需要引入 framework-cloud 就行了,如果要在 Spring Cloud 应用基础上加入数据库分库分表,只需要引入 framework-shard 和相关数据库驱动; * 3、可以让配置统一管理,如 :1、对资源文件解释处理 CSS 字体文件乱码问题;2、统一编码 UTF-8;通过 Maven -P [dev,test,prod] 动态指定开发测试生产环境。 * 4、所有 Maven 工程引用 jar 版本统一管理,都在父级 pom 指定版本,方便 jar 版本更新,和所有项目统一版本。 ## 技术栈 - **基础框架**:Spring Boot 3.3.5 + Spring Cloud 2023.0.5 - **权限管理**:基于 RBAC 模型的通用权限系统,集成 Shiro 2.0.1 - **数据持久化**:MyBatis 3.5.19、Redis、HBase (Phoenix) - **分库分表**:支持数据库分库分表功能 - **链路追踪**:适配 SkyWalking 链路追踪 - **服务治理**:集成 Nacos 服务发现与配置中心 - **API 文档**:集成 Knife4j 接口文档 - **构建工具**:Maven 3.8+ ## 目录结构 ``` framework/ ├── framework-cloud-web/ # Spring Cloud Web 相关功能 ├── framework-auth/ # 认证授权模块 ├── framework-utils/ # 通用工具类 ├── framework-cache/ # 缓存模块 ├── framework-spring-utils/ # Spring 相关工具类 ├── framework-dao/ # 数据访问层 ├── framework-sql-generator/ # SQL 生成器 ├── framework-auth-base/ # 基础认证模块 ├── framework-import-excel/ # Excel 导入模块 ├── framework-shard/ # 分库分表模块 ├── framework-phoenix/ # HBase Phoenix 集成模块 ├── framework-springboot-dependencies/ # Spring Boot 依赖管理 ├── framework-log4j2/ # Log4j2 日志配置 ├── framework-logback/ # Logback 日志配置 ├── spring-cloud-nacos/ # Spring Cloud Nacos 集成 ├── framework-gray/ # 灰度发布模块 ├── framework-dao-mybatisplus/ # MyBatis Plus 集成 ├── framework-wordpress/ # WordPress 集成 ├── framework-jwt/ # JWT 认证模块 ├── auth-test/ # 认证测试模块 ├── doc/ # 文档目录 ├── pom.xml # 父工程 POM 文件 └── README.md # 项目说明文档 ``` ## 核心模块功能详解 ### 1. 认证授权模块 (framework-auth, framework-auth-base) - **基于 RBAC 模型**:实现细粒度的角色权限控制 - **Shiro 集成**:集成 Apache Shiro 2.0.1 实现安全认证 - **JWT 支持**:通过 framework-jwt 模块提供 JWT 认证功能 - **认证基础组件**:framework-auth-base 提供基础认证功能 ### 2. 数据访问模块 (framework-dao, framework-dao-mybatisplus) - **MyBatis 集成**:集成 MyBatis 3.5.19 实现 ORM 功能 - **MyBatis Plus 支持**:通过 framework-dao-mybatisplus 提供增强功能 - **通用 DAO 封装**:提供通用的 CRUD 操作和查询构建器 - **分页支持**:集成 PageHelper 实现数据库分页 ### 3. 缓存模块 (framework-cache) - **Redis 集成**:封装 Redis 操作工具 - **分布式锁**:提供基于 Redis 的分布式锁实现 - **缓存管理**:简化缓存的使用和管理 ### 4. Excel 导入模块 (framework-import-excel) - **通用 Excel 导入**:支持多种数据格式的 Excel 导入 - **数据验证**:提供导入数据的验证机制 - **错误处理**:详细的错误信息和处理流程 ### 5. 分库分表模块 (framework-shard) - **水平分库分表**:支持数据库水平分片 - **分片策略**:提供灵活的分片策略配置 - **简化使用**:降低分库分表的使用复杂度 ### 6. HBase 集成模块 (framework-phoenix) - **Phoenix 框架**:基于 Phoenix 提供关系型数据库体验 - **SQL 支持**:使用标准 SQL 语句操作 HBase - **性能优化**:针对 HBase 的查询性能优化 ### 7. Spring Cloud 相关模块 - **Nacos 集成**:通过 spring-cloud-nacos 模块集成服务发现与配置中心 - **Web 组件**:framework-cloud-web 提供 Web 相关功能 - **灰度发布**:framework-gray 实现服务灰度发布功能 ### 8. 日志模块 (framework-log4j2, framework-logback) - **Log4j2 支持**:集成 Log4j2 日志框架 - **Logback 支持**:集成 Logback 日志框架 - **Redis 到 ELK 支持**:支持将日志通过 Redis 发送到 ELK 日志平台 - **SkyWalking 集成**:适配 SkyWalking 链路追踪 ### 9. 工具模块 (framework-utils, framework-spring-utils) - **通用工具**:framework-utils 提供常用工具类 - **Spring 工具**:framework-spring-utils 提供 Spring 相关工具 - **SQL 生成**:framework-sql-generator 提供 SQL 语句生成功能 ### 10. 其他模块 - **WordPress 集成**:framework-wordpress 提供 WordPress 集成功能 - **依赖管理**:framework-springboot-dependencies 统一管理依赖版本 ## 当前功能 * 通用权限(RBAC)
* Excel 通用导入
* 分库分表模块
* Spring Cloud 通过 Maven 引用最小单元 jar * Redis 持久层工具包
* 数据库持久层 MyBatis
* HBase 持久层 Phoenix 框架
* JWT 认证
* 灰度发布
* Nacos 服务发现与配置中心
* SkyWalking 链路追踪
## 快速开始 ### 1. 环境要求 - JDK 17+ - Maven 3.8+ - Redis (可选,使用缓存功能时需要) - HBase (可选,使用 HBase 功能时需要) - Nacos (可选,使用服务发现功能时需要) ### 2. 安装与配置 #### 方法一:从 Nexus 私服依赖 1. 确保 Nexus 私服已部署本项目 2. 在你的项目 pom.xml 中添加父依赖: ```xml com.framework.concise concise 0.0.1-SNAPSHOT ``` 3. 根据需要引入相应的功能模块: ```xml com.framework.concise framework-auth com.framework.concise framework-shard com.framework.concise framework-dao-mybatisplus ``` #### 方法二:本地导入代码 1. 克隆本项目到本地 2. 执行 Maven 安装命令: ```bash mvn clean install -DskipTests ``` 3. 在你的项目中添加父依赖和所需模块依赖 ### 3. 环境配置 通过 Maven Profiles 动态指定环境: ```bash # 开发环境 mvn clean package -P dev # 测试环境 mvn clean package -P test # 生产环境 mvn clean package -P prod ``` ## 配置说明 ### 1. 统一编码设置 - 默认统一使用 UTF-8 编码 - 自动处理资源文件,解决 CSS 字体文件乱码问题 ### 2. 依赖版本管理 - 所有依赖版本在父工程 pom.xml 中统一管理 - 子模块无需指定版本,继承父工程版本 - 支持 Spring Boot 3.3.5 和 Spring Cloud 2023.0.5 ### 3. 链路追踪配置 - 集成 SkyWalking 链路追踪 - 可通过配置文件调整追踪参数 - 支持 Log4j2 和 Logback 日志框架的链路追踪 ### 4. 服务治理配置 - 集成 Nacos 服务发现与配置中心 - 支持服务注册、发现和配置管理 - 可通过配置文件调整服务治理参数 ## 模块使用示例 ### 1. 认证授权模块使用 ```java // 1. 引入依赖 // // com.framework.concise // framework-auth // // 2. 配置 Shiro // 在 Spring 配置文件中配置 Shiro 相关 bean // 3. 使用注解进行权限控制 @RequiresPermissions("user:view") public List listUsers() { // 方法实现 } ``` ### 2. 数据访问模块使用 ```java // 1. 引入依赖 // // com.framework.concise // framework-dao-mybatisplus // // 2. 定义实体类 @TableName("user") public class User { @TableId private Long id; private String name; // 其他字段和 getter/setter } // 3. 定义 Mapper 接口 public interface UserMapper extends BaseMapper { // 自定义查询方法 } // 4. 使用 Service 层 @Service public class UserService extends ServiceImpl { // 业务逻辑实现 } ``` ### 3. 缓存模块使用 ```java // 1. 引入依赖 // // com.framework.concise // framework-cache // // 2. 使用 Redis 工具类 @Autowired private RedisTemplate redisTemplate; // 3. 操作缓存 public void setCache(String key, Object value) { redisTemplate.opsForValue().set(key, value); } public Object getCache(String key) { return redisTemplate.opsForValue().get(key); } ``` ## 版本管理 - **开发版本**:0.0.1-SNAPSHOT - **发布版本**:请将版本改为如 1.0.0 ## 贡献指南 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) 文件 ## 联系方式 - 项目维护者:[Your Name] - 邮箱:[your.email@example.com] - 问题反馈:[GitHub Issues](https://github.com/yourusername/framework/issues) --- **注意**:本项目持续更新中,更多功能将逐步添加。