LAMP-Cloud与RuoYi-Cloud技术架构对比
文章目录
- 前言
- 一、 企业选型
- 技术选型对比
- 开发效率对比
- 性能表现对比
- 关键优化机制
- 社区支持对比
- 典型应用场景
- 选型决策矩阵
- 最终建议
- 二、架构
- 1.lamp-cloud
- 介绍
- 1.2.架构图
- 1.3 项目组成
- 1.4 数据交互流程设计
- 1.4.1 后端实体资源控制层、业务层、数据层间通信
- 1.4.2 资源实体业务层类SuperManager底层调用流程
- 1.5 框架核心设计规范
- 1.6 架构CURD基础框架抽取(https://gitee.com/harry_software/spring-mvc)
- 2.RuoYi-Cloud [微服务的权限管理系统]
- 介绍
- 2.1.架构图
- 2.2 项目组成
前言
LAMP-Cloud与RuoYi-Cloud 等开源企业管理系统对比与选型。
一、 企业选型
技术选型对比
- LAMP-Cloud技术架构
- 核心组件:
- Spring Cloud Alibaba + Spring Boot 2.7
- 支持Nacos/Consul服务发现
- 集成Sentinel流量控制 + Seata分布式事务
- 技术亮点:
- 多租户SaaS架构支持
- 前端采用Vue3 + Ant Design Vue
- knife4j : Swagger 在线文档
- 支持国产化数据库(达梦/人大金仓)(官方文档)
- RuoYi-Cloud技术架构
- 核心组件:
- Spring Cloud Hoxton + Spring Boot 2.3([5])
- 集成Nacos配置中心 + Sentinel熔断([5])
- 前端采用Vue2 + Element UI([7])
- 技术亮点:
- 代码生成器支持多数据源([5])
- 细粒度权限控制(RBAC+Shiro)([7])
- 内置Swagger3 API文档([5])
开发效率对比
性能表现对比
关键优化机制
- LAMP-Cloud:
- 二级缓存自动装配(Redis+Caffeine)([6])
- SQL防火墙+慢查询监控([2])
- RuoYi-Cloud:
- 接口级限流策略(Sentinel整合)([5])
- Mybatis-Plus性能优化插件([7])
社区支持对比
典型应用场景
LAMP-Cloud适用场景
- 多租户SaaS平台(用户隔离+计费系统)
- 政务云项目(国产化适配需求)
- 中大型企业数字化中台([6])
RuoYi-Cloud适用场景
- 集团级OA/ERP系统(复杂权限体系)
- 政府监管平台(流程审批+报表统计)
- 传统企业数字化转型([5])
- Java EE 企业级快速开发平台。
选型决策矩阵
最终建议
- 若项目涉及政务/金融等合规场景,优先选择LAMP-Cloud的国产化支持
- 对于传统企业管理系统升级,RuoYi-Cloud的成熟生态更具优势
- 在开发团队技术储备方面:Spring Cloud Alibaba技术栈选LAMP,传统Spring Cloud选RuoYi
- lamp-cloud 代码简洁,注释齐全,架构清晰,非常适合个人学习以及中小企业作为基础框架使用
二、架构
1.lamp-cloud
介绍
lamp-cloud是基于java+ SpringCloudAlibaba +SpringCloud+SpringBoot 微服务中后台快速开发平台,专注于多租户 (SaaS架构) 解决方案,已实现 大租户嵌套小租户隔离、数据库隔离、字段隔离、 无租户隔离 等几种模式。
自研RBAC(基于租户应用的角色权限控制体系)、网关统一鉴权、数据权限、优雅缓存解决方案、防缓存击穿、前后端统一表单校验、字典数据自动回显、可视化前后端代码生成器、支持多种文件存储、支持多种短信邮件发送接口、灰度发布、防XSS攻击、防SQL注入、分布式事务、分布式定时任务等功能;
支持多业务系统并行开发、支持多服务并行开发,是中后台系统开发脚手架的最佳选择。
采用Spring Cloud Alibaba、SpringBoot、Mybatis、Seata、Sentinel、RabbitMQ、FastDFS/MinIO、SkyWalking等主要框架和中间件。
1.2.架构图
演示
文档
开源版、赞助版本功能对比
版本费用 开源版: 免费 ,赞助版:需要收费
1.3 项目组成
由"工具集"、“后端”、"前端"几个子项目构成。
工具集
项目 | gitee | github | 备注 |
---|---|---|---|
lamp-util | lamp-util | lamp-util | 核心工具集 |
lamp-job | lamp-job | lamp-job | 分布式定时调度器 |
后端
项目 | gitee | github | 备注 |
---|---|---|---|
lamp-cloud | lamp-cloud | lamp-cloud | 微服务和单体模式融合版 |
前端
项目 | gitee | github | 备注 |
---|---|---|---|
lamp-web | lamp-web | lamp-web | 基于 vben-admin |
后端项目Module
lamp-support 服务启动服务modulelamp-system-server 单体版系统服务启动服务lamp-job-server 单体版定时任务执行器lamp-monitor 单体版应用监控中心lamp-gateway 网关服务lamp-gateway-server 网关服务启动模块lamp-gateway-biz 网关服务插件lamp-oauth 认证服务lamp-oauth-server 启动模块lamp-oauth-controller控制器模块(接口模块)lamp-oauth-biz 业务模块lamp-oauth-facade 接口层门面lamp-oauth-entity 实体模块[认证Grant类型、认证相关参数Vo和响应Vo]lamp-system 系统服务lamp-system-server 启动模块,映射/systemlamp-system-controller控制器模块(接口模块)lamp-system-biz 业务模块lamp-system-facade 接口层门面lamp-system-entity 实体模块[应用、用户、系统资源、消息等]lamp-base 基础服务modulelamp-base-server 启动模块,映射/base lamp-base-controller 控制器模块lamp-base-biz 业务模块 lamp-base-facade 接口层门面lamp-base-entity 基础服务实体模块[员工、角色、部门、文件、日志、消息等] lamp-public 业务相关公共模块lamp-common 基础工具类、常量、枚举、注解annotation、异常等lamp-model 基础模型实体[用户、员工、部门、岗位、角色、资源]等lamp-login-user-facade登录用户自动注入模块lamp-login-user-boot-impl 单体版本具体实现lamp-login-user-cloud-impl微服务微具体实现,@FeignClient(name = "lamp.feign.base-server:lamp-base-server")lamp-database-mode 多租户模式具体实现[暂未实现,赞助版已实现]lamp-file-sdk 业务文件sdklamp-data-scope-sdk 数据权限[暂未实现,赞助版已实现]lamp-sa-token-ext sa-token扩展包lamp-generator 在线代码生成器模块服务
1.4 数据交互流程设计
1.4.1 后端实体资源控制层、业务层、数据层间通信
业务流程线
实体业务控制层Controller 保存:SaveController类save(@RequestBody @Validated SaveVO saveVO)
--------> SuperCacheController类 [this.getSuperService().save(saveVO)]
--------> SuperServiceImpl类[ public Entity save(SaveVO saveVO) ]
-------->SuperCacheManagerImpl类[public boolean save(T model) ]
业务流程调用图
代码走读
资源实体(如员工BaseEmployeeController )控制层
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/baseEmployee")
@Tag(name = "员工")
public class BaseEmployeeController extends SuperCacheController<
BaseEmployeeService, Long, BaseEmployee,
BaseEmployeeSaveVO, BaseEmployeeUpdateVO,
BaseEmployeePageQuery, BaseEmployeeResultVO> {............CURD:实现类由SaveController<Id, Entity, SaveVO>, UpdateController<Id, Entity, UpdateVO>, DeleteController<Id, Entity>, QueryController<Id, Entity, PageQuery, ResultVO> 等实现类实现......}
父类通用控制层SuperController
/*
* 1) 泛化资源实体服务层父类SuperService
* 2) 泛化资源实体Entity、新增体SaveVO、编辑体UpdateVO、
* 分页查询体PageQuery、响应体ResultVO等
* 3) extends SuperSimpleController父类Simple控制层
* 4) implements新增、编辑、删除、分页查询等各Controller控制层
*/
public abstract class SuperController<S extends SuperService<Id, Entity>, Id extends Serializable, Entity extends SuperEntity<Id>, SaveVO, UpdateVO, PageQuery, ResultVO> extends SuperSimpleController<S, Id, Entity> implements SaveController<Id, Entity, SaveVO>,UpdateController<Id, Entity, UpdateVO>, DeleteController<Id, Entity>, QueryController<Id, Entity, PageQuery, ResultVO> {protected Class<ResultVO> resultVOClass = this.currentResultVOClass();public SuperController() {}protected Class<ResultVO> currentResultVOClass() {return ReflectionKit.getSuperClassGenericType(this.getClass(), SuperController.class, 6);}public Class<ResultVO> getResultVOClass() {return this.resultVOClass;}
}父类Simple控制层SuperSimpleController
/*
* 1) 定义资源实体服务层父类SuperService,如 :实例化员工服务 BaseEmployeeService.java
* 2) 定义资源实体类Entity 如:员工实体类BaseEmployee.java
*/
public abstract class SuperSimpleController<S extends SuperService<Id, Entity>, Id extends Serializable, Entity extends SuperEntity<Id>> implements BaseController<Id, Entity> {//定义业务实现层Service和接口类对象:S extends SuperService<Id, Entity>@Autowiredprotected S superService;protected Class<Entity> entityClass = this.currentModelClass();public SuperSimpleController() {}protected Class<Entity> currentModelClass() {return ReflectionKit.getSuperClassGenericType(this.getClass(), SuperSimpleController.class, 2);}public Class<Entity> getEntityClass() {return this.entityClass;}public SuperService<Id, Entity> getSuperService() {return this.superService;}
}
资源实体的新增(保存操作)业务控制层Controller:SaveController
/*
* 说明:this.getSuperService().save(saveVO) 执行表单元素save操作
*/
public interface SaveController<Id extends Serializable,Entity extends SuperEntity<Id>, SaveVO> extends BaseController<Id, Entity> {default R<Entity> save(@RequestBody @Validated SaveVO saveVO) {R<Entity> result = this.handlerSave(saveVO);return result.getDefExec() ? R.success(this.getSuperService().save(saveVO)) : result;}default R<Entity> copy(@RequestParam("id") Id id) {return R.success(this.getSuperService().copy(id));}default R<Entity> handlerSave(SaveVO model) {return R.successDef();}
}
资源实体通用业务层实现类父类 SuperServiceImpl
/*
* 1) implements资源实体业务层类SuperService的实现新增、编辑、删除、分页查询等各方法体
* 2) 泛化资源实体SuperManager,并定义M superManager
* 3) 泛化资源实体Entity
* 4) 将资源实体业务层类新增、编辑、删除、分页查询等实现下钻到SuperManager, 即this.getSuperManager().save(entity);
*/
public class SuperServiceImpl<M extends SuperManager<Entity>, Id extends Serializable, Entity extends SuperEntity<?>> implements SuperService<Id, Entity> {@Autowiredprotected M superManager;protected Class<M> managerClass = this.currentManagerClass();protected Class<Entity> entityClass = this.currentModelClass();protected Class<Id> idClass = this.currentIdClass();.....@Transactional(rollbackFor = {Exception.class})public <SaveVO> Entity save(SaveVO saveVO) {Entity entity = this.saveBefore(saveVO);this.getSuperManager().save(entity);this.saveAfter(saveVO, entity);return entity;}................@Transactional(rollbackFor = {Exception.class})public <UpdateVO> Entity updateById(UpdateVO updateVO) {Entity entity = this.updateBefore(updateVO);this.getSuperManager().updateById(entity);this.updateAfter(updateVO, entity);return entity;}................@Transactional(rollbackFor = {Exception.class})public boolean removeByIds(Collection<Id> idList) {return this.getSuperManager().removeByIds(idList);}@Transactional(readOnly = true)public Entity getById(Id id) {return (SuperEntity)this.getSuperManager().getById(id);}@Transactional(readOnly = true)public List<Entity> list(Wrapper<Entity> queryWrapper) {return this.getSuperManager().list(queryWrapper);}@Transactional(readOnly = true)public List<Entity> listByIds(List<Id> ids) {return this.getSuperManager().listByIds(ids);}@Transactional(readOnly = true)public <E extends IPage<Entity>> E page(E page, Wrapper<Entity> queryWrapper) {return this.getSuperManager().page(page, queryWrapper);}
}
this.getSuperManager().save(entity)调用SuperManager实现资源的save,具体流程见下述"1.4.2 资源实体业务层类SuperManager底层调用流程"
1.4.2 资源实体业务层类SuperManager底层调用流程
流程图:
代码走读:
资源实体业务层类SuperManager新增、编辑、删除、分页查询等实现追溯到到mybatisplus数据层Mapper流程。
SuperServiceImpl类:
public <SaveVO> Entity save(SaveVO saveVO) { this.getSuperManager().save(entity);}
说明:getSuperManager获取父类SuperManager,或者资源实体Manager,如BaseEmployeeManager
-> SuperCacheManagerImpl类(SuperCacheManagerImpl为SuperManager的实现类):
public boolean save(T model) {boolean save = super.save(model);.........
}
说明:super为SuperManager,继承IService(如public interface SuperManager extends IService )
-> IService 类:
default boolean save(T entity) {return SqlHelper.retBool(this.getBaseMapper().insert(entity));}
-> ServiceImpl类:
public M getBaseMapper() {Assert.notNull(this.baseMapper, "baseMapper can not be null", new Object[0]);return this.baseMapper;
}
说明:baseMapper为mybatisplus基础Mapper、也被其它实体资源Mapper继承,如BaseEmployeeMapper
-> BaseMapper类(实现资源的CURD):
public interface BaseMapper<T> extends Mapper<T> {int insert(T entity);..................int updateById(@Param("et") T entity);default int deleteById(Serializable id) ; T selectById(Serializable id);}
1.5 框架核心设计规范
借鉴阿里规范,采用了5层调用模型 controller -> biz -> service -> manager -> mapper, 其中biz层时可选的,调用只能从上往下,不能反着调用,最好也不要平层交叉调用。
controller:请求转发
biz(可选):
- 1.处理不同数据源的业务逻辑。
- 2.可能存在分布式事务(不能使用本地事务,即该层方法或类上不能加@Transactional)
- 3.当某个业务仅仅只会操作一个具体的数据源时,可以不要biz层,直接使用service层
service
- 1.控制事务,对于复杂的业务应避免service互相依赖
- 2.处理同一数据源的业务逻辑,save方法更加贴切实际业务
manager :save方法只负责单个表的保存操作(可以对字段进行一些默认值设置)
mapper:mapper的insert 方法只负责原封不动的插入数据。
业务层调度流程图
控制层:
业务层:
1.6 架构CURD基础框架抽取(https://gitee.com/harry_software/spring-mvc)
2.RuoYi-Cloud [微服务的权限管理系统]
介绍
RuoYi-Cloud 是一个 Java EE 分布式微服务架构平台,基于经典技术组合(Spring Boot、Spring Cloud & Alibaba、Vue、Element),内置模块如:部门管理、角色用户、菜单及按钮授权、数据权限、系统参数、日志管理、代码生成等。在线定时任务配置;支持集群,支持多数据源。
MIT开源协议允许开发者自由使用和二次开发,仅需保留原始版权声明。
2.1.架构图
演示 admin/admin123
文档
2.2 项目组成
com.ruoyi
├── ruoyi-ui // 前端框架 [80]
├── ruoyi-gateway // 网关模块 [8080]
├── ruoyi-auth // 认证中心 [9200]
├── ruoyi-api // 接口模块
│ └── ruoyi-api-system // 系统接口
├── ruoyi-common // 通用模块
│ └── ruoyi-common-core // 核心模块
│ └── ruoyi-common-datascope // 权限范围
│ └── ruoyi-common-datasource // 多数据源
│ └── ruoyi-common-log // 日志记录
│ └── ruoyi-common-redis // 缓存服务
│ └── ruoyi-common-seata // 分布式事务
│ └── ruoyi-common-security // 安全模块
│ └── ruoyi-common-sensitive // 数据脱敏
│ └── ruoyi-common-swagger // 系统接口
├── ruoyi-modules // 业务模块
│ └── ruoyi-system // 系统模块 [9201]
│ └── ruoyi-gen // 代码生成 [9202]
│ └── ruoyi-job // 定时任务 [9203]
│ └── ruoyi-file // 文件服务 [9300]
├── ruoyi-visual // 图形化管理模块
│ └── ruoyi-visual-monitor // 监控中心 [9100]
├──pom.xml // 公共依赖