# 易狗微服务开发框架v4.0 **Repository Path**: ego-team/ego-cloud ## Basic Information - **Project Name**: 易狗微服务开发框架v4.0 - **Description**: 易狗微服务开发框架 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 8 - **Forks**: 0 - **Created**: 2026-04-11 - **Last Updated**: 2026-05-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
# ego-cloud v4.0.0 ## 基于 Vue/Element-plus 和 Spring Boot / Spring Cloud Alibaba 的前后端分离分布式微服务架构 ![ego version](https://img.shields.io/badge/ego-v4.0.0-brightgreen.svg) ![License](https://img.shields.io/github/license/mashaper/apistatus.svg) ![Java](https://img.shields.io/badge/Java-21-orange.svg) ![Spring Boot](https://img.shields.io/badge/Spring%20Boot-4.0.2-green.svg) ![Spring Cloud](https://img.shields.io/badge/Spring%20Cloud-2025.1.0-blue.svg) ![Vue](https://img.shields.io/badge/Vue-2.6.12-brightgreen.svg)
--- [OAuth2RefreshTokenGenerator.java](ego-applications/ego-auth/ego-auth-app/src/main/java/com/ego/auth/token/OAuth2RefreshTokenGenerator.java) ## 项目简介 **ego-cloud** 是易狗微服务开发框架,采用前后端分离的分布式微服务架构,遵循 **领域驱动设计(DDD)** 分层模式,提供完整的企业级开箱即用解决方案。 框架内置用户权限、多租户隔离、操作日志、链路追踪、分布式事务、数据脱敏等核心能力,开发者只需专注于业务逻辑,无需重复造轮子。 ### 核心特性 | 特性 | 说明 | |------|------| | **微服务架构** | 基于 Spring Cloud & Alibaba,支持服务注册、配置中心、熔断限流 | | **DDD 分层设计** | app / domain / infrastructure / client 四层架构,职责清晰,边界明确 | | **前后端分离** | Vue3 + Element Plus + Vite 与 Spring Boot REST API 完全解耦 | | **组件化 Starter** | 缓存、消息、搜索、Excel 等组件独立可插拔 | | **多租户支持** | 框架级 SQL 租户隔离(TenantLineInterceptor),业务层无感知 | | **数据脱敏** | 注解驱动字段脱敏(手机号、身份证、银行卡等) | | **分布式能力** | 分布式事务(Seata)、分布式锁(Redisson)、分布式缓存(Redis) | | **完善监控** | SkyWalking 链路追踪、SkyWalking Agent 探针、Spring Boot Admin | | **安全防护** | Spring Security + OAuth2 + JWT Token + 接口签名校验 | --- ## 技术选型 | 类别 | 技术方案 | 版本 | |------|-----------------------------|------| | Java 版本 | OpenJDK | 21 | | 中间件 | Tomcat | 11.0.20 | | 后端框架 | Spring Boot | 4.0.2 | | 微服务框架 | Spring Cloud | 2025.1.0 | | 微服务框架 | Spring Cloud Alibaba | 2025.1.1.0 | | 微服务网关 | Spring Cloud Gateway (WebFlux) | 5.0.1 | | OAuth2 认证 | Spring Authorization Server | 4.0.2 | | JSON 框架 | Fastjson2 | 2.0.57 | | 注册/配置中心 | Nacos | 3.2.1 | | 服务监控 | Spring Boot Admin | 4.0.2 | | 链路追踪 | Apache SkyWalking | 9.6.0 | | ORM 框架 | MyBatis Plus | 3.5.8 | | 缓存框架 | Spring Data Redis / Ehcache | 4.0.2 | | 分布式锁 | Redisson | 4.3.1 | | 消息队列 | RabbitMQ / Kafka | 3.9+ / 2.13+ | | 搜索引擎 | Elasticsearch | 7.15.2 | | 安全框架 | Spring Security + JWT | 7.0.2 / 0.13.0 | | 前端框架 | Vue | 2.6.12 | | UI 组件库 | Element-plus | 2.14.0 | | 业务组件库 | Vue | 3.5.34 | --- ## 项目结构 ``` ego-cloud ├── framework-config # Nacos 基础配置文件 ├── ego-framework # 框架层(不含业务) │ ├── framework-base # 基础类:Response、PageQuery、BaseDO、注解等 │ ├── framework-core # 核心工具:BeanToolkit、JwtUtils、DateUtils 等 │ ├── framework-web-starter # Web 自动配置(全局异常、拦截器等) │ └── framework-components # 各功能 Starter 组件 │ ├── framework-security-starter # 安全组件(签名校验、Token 拦截、脱敏) │ ├── framework-elasticsearch-starter # Elasticsearch 搜索引擎组件 │ ├── framework-event-starter # 事件发布与监听组件 │ ├── framework-excel-starter # Excel 导入导出组件 │ ├── framework-milvus-starter # milvus 向量数据组件 │ ├── framework-jdbc-starter # JDBC / MyBatis Plus 数据库组件 │ ├── framework-rabbit-starter # RabbitMQ 消息组件 │ ├── framework-redis-starter # Redis 缓存 / 分布式锁组件 │ ├── framework-metrics-starter # 统计监控组件 │ ├── framework-mock-starter # 数据模拟组件 │ └── framework-validation-starter # 数据校验组件 ├── ego-applications # 业务服务层 │ ├── ego-gateway # 网关服务 [8080] │ │ └── src │ ├── ego-auth # 认证授权服务(OAuth2) │ │ ├── ego-auth-bootstrap # 启动类 │ │ ├── ego-auth-client # DTO / Feign 客户端接口 │ │ ├── ego-auth-app # 应用层(Executor + Service + Controller) │ │ ├── ego-auth-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ └── ego-auth-infrastructure # 基础设施层(Repository + DO + Mapper) │ ├── ego-system # 系统管理服务(DDD 分层架构) │ │ ├── ego-system-bootstrap # 启动类 │ │ ├── ego-system-client # DTO / Feign 客户端接口 │ │ ├── ego-system-app # 应用层(Executor + Service + Controller) │ │ ├── ego-system-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ ├── ego-system-infrastructure # 基础设施层(Repository + DO + Mapper) │ │ └── ego-system-job-starter # 业务启动器 │ ├── ego-openapi # API 接口管理服务 │ │ ├── ego-openapi-bootstrap # 启动类 │ │ ├── ego-openapi-client # DTO / Feign 客户端接口 │ │ ├── ego-openapi-app # 应用层(Executor + Service + Controller) │ │ ├── ego-openapi-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ ├── ego-openapi-infrastructure # 基础设施层(Repository + DO + Mapper) │ │ └── ego-openapi-starter # 接口同步器 │ ├── ego-base # 基础数据服务(DDD分层架构) │ │ ├── ego-base-bootstrap # 启动类 │ │ ├── ego-base-client # DTO / Feign 客户端接口 │ │ ├── ego-base-app # 应用层(Executor + Service + Controller) │ │ ├── ego-base-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ └── ego-base-infrastructure # 基础设施层(Repository + DO + Mapper) │ ├── ego-file # 文件存储服务(DDD分层架构) │ │ ├── ego-file-bootstrap # 启动类 │ │ ├── ego-file-client # DTO / Feign 客户端接口 │ │ ├── ego-file-app # 应用层(Executor + Service + Controller) │ │ ├── ego-file-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ └── ego-file-infrastructure # 基础设施层(Repository + DO + Mapper) │ ├── ego-log # 日志收集服务(DDD分层架构) │ │ ├── ego-log-bootstrap # 启动类 │ │ ├── ego-log-client # DTO / Feign 客户端接口 │ │ ├── ego-log-app # 应用层(Executor + Service + Controller) │ │ ├── ego-log-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ ├── ego-log-infrastructure # 基础设施层(Repository + DO + Mapper) │ │ └── ego-log-starter # 业务启动器 │ ├── ego-msg # 消息通知服务(DDD分层架构) │ │ ├── ego-msg-bootstrap # 启动类 │ │ ├── ego-msg-client # DTO / Feign 客户端接口 │ │ ├── ego-msg-app # 应用层(Executor + Service + Controller) │ │ ├── ego-msg-domain # 领域层(Gateway 接口 + 领域服务 + 领域事件 + 领域模型) │ │ └── ego-msg-infrastructure # 基础设施层(Repository + DO + Mapper) │ ├── ego-monitor # 服务监控(Spring Boot Admin) │ └── ego-demo # 示例服务(经典三层架构) │ ├── ego-demo-app # 应用层(Executor + Service + Controller) │ ├── ego-demo-client # DTO / Feign 客户端接口 │ └── ego-demo-infrastructure # 基础设施层(Repository + DO + Mapper) └── ego-ui └── ego-cmp # 中台前端(Vue 2 + Element UI + Avue) ``` ### 业务服务子模块(DDD 架构) 每个业务服务固定包含以下子模块: | 子模块 | 职责 | |--------|------| | `ego-{svc}-bootstrap` | 启动类(SpringApplication.run) | | `ego-{svc}-client` | 对外暴露的 DTO(VO/Cmd/Qry)、Feign API 接口 | | `ego-{svc}-app` | 应用层:Executor + Service + Controller | | `ego-{svc}-domain` | 领域层:Gateway 接口 + DomainService | | `ego-{svc}-infrastructure` | 基础设施层:Repository 实现 + DO + Mapper | | `ego-{svc}-starters` | 业务启动器(安全/MyBatis Plus 等配置) | ### 架构调用链 ``` HTTP 请求 ↓ 网关(ego-gateway) # 路由转发、Token 校验、签名验证、限流 ↓ Controller(web 层) # 接收请求,参数绑定 ↓ Service(service 层) # Executor 编排与聚合 ↓ Executor(executor 层) # 最细粒度业务单元(QueryExe / SaveExe / DeleteExe) ↓ Gateway 接口(domain 层) # 领域层定义,依赖倒置 ↑ 实现 Repository(infrastructure 层) # MyBatis Plus 数据访问 ↓ 数据库(MySQL) ``` ### 包命名规范 ``` com.ego.{svc}. ├── dto.cmd.{domain}/ # 命令对象(在 client 模块) ├── dto.query.{domain}/ # 查询对象(在 client 模块) ├── dto.vo.{domain}/ # 视图对象(在 client 模块) ├── api/ # Feign 客户端接口(在 client 模块) ├── gateway/ # Gateway 接口(在 domain 模块) ├── domainservice/ # 领域服务(在 domain 模块) ├── repository/ # Repository 实现(在 infrastructure 模块) ├── repository.dataobject/ # DO 数据对象(在 infrastructure 模块) ├── repository.mapper/ # MyBatis Plus Mapper(在 infrastructure 模块) ├── executor.{domain}/ # 业务执行器(在 app 模块) ├── service/ # Service 服务类(在 app 模块) ├── web/ # Controller(在 app 模块) └── job/ # 定时任务(在 app 模块) ``` --- ## 内置功能 | 序号 | 功能模块 | 功能描述 | |------|----------|----------| | 1 | 用户管理 | 系统操作用户管理,支持多组织架构 | | 2 | 部门管理 | 组织机构树形管理,支持数据权限划分 | | 3 | 岗位管理 | 系统用户岗位职务配置 | | 4 | 菜单管理 | 系统菜单、操作权限、按钮权限标识配置 | | 5 | 角色管理 | 角色菜单权限分配,支持按机构数据范围隔离 | | 6 | 字典管理 | 系统固定数据字典维护 | | 7 | 参数管理 | 系统动态参数配置 | | 8 | 通知公告 | 系统通知公告发布与维护 | | 9 | 操作日志 | 系统正常/异常操作日志记录与查询 | | 10 | 登录日志 | 系统登录记录查询(含异常登录) | | 11 | 运行日志 | 各微服务运行日志队列收集与分析查询 | | 12 | 在线用户 | 活跃用户实时状态监控 | | 13 | 定时任务 | 在线任务调度管理,含执行结果日志 | | 14 | 系统接口 | 基于业务代码自动生成 API 接口文档 | | 15 | 服务监控 | CPU、内存、磁盘、堆栈等系统资源监控 | | 16 | 在线构建器 | 拖拽表单元素生成对应 HTML 代码 | | 17 | 多租户隔离 | 框架级 SQL 租户隔离,业务层无感知 | | 18 | 数据脱敏 | 注解驱动字段脱敏输出(手机号/身份证/银行卡等) | --- ## 快速开始 ### 环境要求 | 中间件 | 版本要求 | 说明 | |--------|-------|--------------------------------------------| | JDK | 21+ | OpenJDK 21 | | Maven | 3.6+ | 构建工具 | | Node.js | 16.x | 前端构建工具(高版本无法运行 Vue 2 前端) | | MySQL | 8.0+ | 关系型数据库 | | Redis | 7.0+ | 缓存 / 分布式锁,版本低于 6.2.0 不支持批量 LPOP,Redis队列性能低 | | Nacos | 3.0+ | 注册中心 / 配置中心 | | RabbitMQ | 3.9+ | 消息队列(选装) | | Kafka | 2.13+ | 消息队列(选装) | | elasticsearch | 7.0+ | 全文搜索引擎(选装) | ### 中间件安装 MySQL、Redis、Nacos 预置安装包(含初始化 SQL): ``` 网盘地址:https://pan.baidu.com/s/1CjoHA6tOihNb1-yoDGdmDg?pwd=5ki1 启动命令(nacos 依赖 mysql): 1. mysql-startup.bat 2. nacos-startup.bat 3. redis-startup.bat MySQL 账号:root/root,ego/ego123456 Nacos 访问:http://localhost:8848 Nacos 账号:nacos/nacos123456 ``` ### 后端启动 **1. 编译安装框架模块** ```bash # 安装基础模块 cd ego-framework/framework-base && mvn clean install -DskipTests # 安装核心模块 cd ../framework-core && mvn clean install -DskipTests # 安装 Starter 模块(也可直接在 framework-starters 根目录执行) cd ../framework-starters && mvn clean install -DskipTests ``` **2. 编译安装应用模块** ```bash 1.首先安装每个应用的 client 模块(作为二方库依赖) 2.安装[ego-openapi-starter](ego-applications/ego-api/ego-openapi-starter)ego-openapi-starter 3.安装[ego-log-starter](ego-applications/ego-log/ego-log-starter) 4.安装[ego-system-job-starters](ego-applications/ego-system/ego-system-job-starters) ``` **3. 启动应用服务** > JVM 启动参数(解决 Java 21 模块系统访问限制): > ``` > --add-opens java.base/java.lang.reflect=ALL-UNNAMED > --add-opens java.base/java.lang=ALL-UNNAMED > --add-opens java.base/java.time=ALL-UNNAMED > ``` 建议启动顺序: ```bash # 1. 网关服务 cd ego-applications/ego-gateway && mvn spring-boot:run # 2. 认证授权服务 cd ../ego-auth/ego-auth-bootstrap && mvn spring-boot:run # 3. 系统管理服务 cd ../ego-system/ego-system-bootstrap && mvn spring-boot:run # 4. 基础服务 cd ../ego-base/ego-base-bootstrap && mvn spring-boot:run # 5. 文件服务 cd ../ego-file/ego-file-bootstrap && mvn spring-boot:run # 6. 日志服务 cd ../ego-log/ego-log-bootstrap && mvn spring-boot:run # 7. 消息服务 cd ../ego-msg/ego-msg-bootstrap && mvn spring-boot:run # 8. 监控服务 cd ../ego-monitor && mvn spring-boot:run ``` 打包运行完整命令示例: ```bash java -jar -Xms128m -Xmx512m \ --add-opens java.base/java.lang.reflect=ALL-UNNAMED \ --add-opens java.base/java.lang=ALL-UNNAMED \ --add-opens java.base/java.time=ALL-UNNAMED \ -Dspring.profiles.active=dev \ ego-xxxx-bootstrap.jar ``` ### 前端启动 ```bash # 1. 安装依赖 cd ego-ui/ego-cmp pnpm install # 2. 启动开发服务器 pnpm run dev ``` 访问地址:`http://localhost:80` 管理员账号:admin/admin2026 --- ## 系统截图
--- ## 开发文档 - **[前端开发指南](docs/前端-开发指引.md)** - Vue 前端开发规范、组件使用、API 调用等 - **[后端开发指南](docs/后端-开发指引.md)** - Java 后端开发规范、DDD 架构设计、框架组件使用等 --- ## 技术支持 - QQ 群:759569549 ## 开源协议 [MIT License](./LICENSE)