资讯动态

JEECG Boot整合Flowable 6.5.0实战:从权限配置到流程发布的完整避坑指南

发布时间:2026/8/7 15:06:56 来源:尧图企业网站定制
JEECG Boot深度整合Flowable 6.5.0全流程实战从权限体系设计到流程引擎调优当企业级应用需要引入工作流引擎时JEECG Boot与Flowable的整合往往成为Java开发团队的首选方案。这种组合既能享受JEECG快速开发的优势又能获得Flowable强大的流程管理能力。但在实际落地过程中开发者常会遇到权限体系冲突、用户身份识别异常、前后端对接不畅等典型问题。本文将基于6.5.0版本分享一套经过生产验证的整合方案。1. 工程架构设计与核心依赖配置1.1 子模块化工程结构规划推荐采用Maven多模块架构将Flowable相关功能独立为子模块。这种设计既保持了解耦性又便于后续扩展。在父工程pom.xml中定义版本管理properties flowable.version6.5.0/flowable.version /properties子模块需引入的关键依赖包括dependencies !-- JEECG基础依赖 -- dependency groupIdorg.jeecgframework.boot/groupId artifactIdjeecg-boot-base-common/artifactId /dependency !-- Flowable核心引擎 -- dependency groupIdorg.flowable/groupId artifactIdflowable-spring-boot-starter/artifactId version${flowable.version}/version /dependency !-- 模型设计器REST API -- dependency groupIdorg.flowable/groupId artifactIdflowable-ui-modeler-rest/artifactId version${flowable.version}/version exclusions exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-log4j2/artifactId /exclusion /exclusions /dependency !-- 管理控制台配置 -- dependency groupIdorg.flowable/groupId artifactIdflowable-ui-admin-conf/artifactId version${flowable.version}/version /dependency /dependencies1.2 数据库连接特殊配置Flowable对数据库元数据获取有特殊要求需在JDBC URL中添加关键参数spring: datasource: url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?nullCatalogMeansCurrenttruecharacterEncodingUTF-8注意nullCatalogMeansCurrenttrue参数对MySQL连接至关重要缺失会导致Flowable启动时无法正确识别数据库表结构。2. 权限体系深度整合方案2.1 解决anonymousUser身份问题原生Flowable与JEECG的Shiro权限体系存在冲突直接集成会导致流程发起人显示为anonymousUser。我们需要重写身份获取逻辑Component public class FlowableStartedListener implements ApplicationListenerContextRefreshedEvent{ Override public void onApplicationEvent(ContextRefreshedEvent event) { Authentication.setAuthenticationContext(new MyAuthenticationContext()); } } public class MyAuthenticationContext implements AuthenticationContext { Override public String getAuthenticatedUserId() { // 与JEECG的Shiro体系对接 LoginUser sysUser (LoginUser)SecurityUtils.getSubject().getPrincipal(); return sysUser ! null ? sysUser.getId() : null; } }2.2 安全配置优化关闭CSRF防护并配置URL白名单Configuration EnableWebSecurity public class FlowbleSecurityConfiguration extends WebSecurityConfigurerAdapter { Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests() .antMatchers(/flowable/**, /app/**).permitAll() .anyRequest().authenticated(); } Bean public HttpFirewall allowUrlEncodedSlashHttpFirewall() { return new DefaultHttpFirewall(); } }关键配置项说明配置项作用推荐值csrf().disable()关闭跨站请求伪造防护必须关闭antMatchers()开放Flowable相关路径/flowable/**HttpFirewall允许URL特殊字符必须配置3. 流程模型发布与部署实战3.1 增强型流程发布控制器原生模型发布接口往往不能满足企业需求我们需要扩展发布逻辑RestController RequestMapping(/app) public class MyModelResources { Autowired private RepositoryService repositoryService; PostMapping(publish/{modelId}) public JSONObject publish(PathVariable String modelId) { Model model modelService.getModel(modelId); BpmnModel bpmnModel modelService.getBpmnModel(model); Deployment deployment repositoryService.createDeployment() .addBpmnModel(model.getName() .bpmn20.xml, bpmnModel) .name(model.getName()) .key(model.getKey()) .tenantId(model.getTenantId()) .deploy(); JSONObject result new JSONObject(); result.put(deploymentId, deployment.getId()); result.put(deploymentTime, deployment.getDeploymentTime()); return result; } }3.2 流程定义缓存处理高频发布时需注意缓存清理// 发布后清理缓存 repositoryService.createDeploymentQuery() .deploymentId(deploymentId) .singleResult(); processEngine.getProcessEngineConfiguration() .getProcessDefinitionCache() .clear();4. 前端深度整合方案4.1 模型设计器嵌入技巧将Flowable Modeler整合到JEECG前端框架时需要注意静态资源放置到public/flowable目录修改app-cfg.js中的基础路径配置添加Token传递拦截器// providers-config.js request: function(config) { config.headers config.headers || {}; if (localStorage.getItem(pro__Access-Token)) { config.headers[X-Access-Token] JSON.parse(localStorage.getItem(pro__Access-Token)).value; } return config; }4.2 Vue组件封装方案创建可复用的流程设计器组件template div classflowable-container iframe src/flowable/index.html :styleiframeStyle loadonIframeLoad /iframe /div /template script export default { data() { return { iframeStyle: { width: 100%, height: calc(100vh - 180px), border: none } } }, methods: { onIframeLoad() { console.log(Flowable designer loaded); } } } /script5. 生产环境调优建议5.1 性能关键参数配置在application.yml中添加Flowable性能配置flowable: async-executor-activate: true async-executor: core-pool-size: 10 max-pool-size: 50 queue-size: 1000 process: definition-cache-limit: 1005.2 历史数据归档策略对于高频流程系统建议配置历史数据清理-- 创建归档表 CREATE TABLE ACT_HI_PROCINST_ARCH LIKE ACT_HI_PROCINST; -- 设置自动归档任务 flowable: history-level: audit history-cleanup: enabled: true batch-size: 100 time-window: P30D在实际项目落地过程中我们发现最大的挑战往往不在于技术实现而在于权限体系的无缝对接。通过重写SecurityUtils和AuthenticationContext我们成功解决了JEECG与Flowable的身份识别冲突问题。对于需要深度定制的团队建议重点关注流程节点与JEECG权限标签的联动设计。

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价