因公司需求需要将flowable的流程设计器集成到项目中,下面将最近的研究成果记录一下。


文章目录

  • 一、下载flowable-modeler源码
  • 二、添加相关maven包
  • 三、调用idm服务重新接口
  • 四、配置类
  • 五、启动类跳过登陆拦截
  • 六、配置文件

一、下载flowable-modeler源码

  • 把flowable-ui-modeler-app\src\main\resources\static下面的代码拷贝至我们自己的工程

二、添加相关maven包

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.7.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.gblfy</groupId><artifactId>flowable</artifactId><version>0.0.1-SNAPSHOT</version><name>flowable_modeler</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!--去除本身的logback,使用log4j,如果想要使用logback需要添加commons-logging--><exclusions><!-- 去除旧log依赖 --><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><exclusions><!--去除本身的logback,使用log4j,如果想要使用logback需要添加commons-logging--><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId></exclusion></exclusions><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/commons-io/commons-io --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.6</version></dependency><dependency><groupId>org.flowable</groupId><artifactId>flowable-groovy-script-static-engine</artifactId><version>6.4.1</version></dependency><dependency><groupId>org.codehaus.groovy</groupId><artifactId>groovy-all</artifactId><version>2.5.4</version><type>pom</type></dependency><!-- https://mvnrepository.com/artifact/commons-io/commons-io --><dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.6</version></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.0.0</version></dependency><!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-core --><dependency><groupId>org.liquibase</groupId><artifactId>liquibase-core</artifactId><version>3.6.2</version></dependency><!-- Logging --><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>${slf4j.version}</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>${slf4j.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-test --><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.0.9.RELEASE</version></dependency><!-- https://mvnrepository.com/artifact/org.flowable/flowable-spring-boot-starter-process --><dependency><groupId>org.flowable</groupId><artifactId>flowable-spring-boot-starter-process</artifactId><version>6.4.1</version></dependency><dependency><groupId>org.flowable</groupId><artifactId>flowable-ui-modeler-rest</artifactId><version>6.4.1</version></dependency><!-- dbpool的jar --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.12</version></dependency><!-- mysql驱动包 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.28</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

三、调用idm服务重新接口

  • flowable获取用户是调用idm服务,这里前端修改获取用户信息接口自己实现接口
package com.gblfy.flowable.controller;import org.flowable.idm.api.User;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.flowable.ui.common.model.UserRepresentation;
import org.flowable.ui.common.security.SecurityUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;/*** @ClassName GblfyRemoteAccountResource* @Description 內置用户登录* @Author gblfy* @Date 2019/11/17 20:12*/
@RestController
@RequestMapping("/gblfy")
public class GblfyRemoteAccountResource {/*** GET /rest/account -> get the current user.*/@RequestMapping(value = "/rest/account", method = RequestMethod.GET, produces = "application/json")public UserRepresentation getAccount() {User user=new UserEntityImpl();user.setId("gblfy");SecurityUtils.assumeUser(user);UserRepresentation userRepresentation = new UserRepresentation();userRepresentation.setId("gblfy");userRepresentation.setFirstName("gblfy");List<String> privileges=new ArrayList<>();privileges.add("flowable-idm");privileges.add("flowable-modeler");privileges.add("flowable-task");userRepresentation.setPrivileges(privileges);return  userRepresentation;}
}

四、配置类

package com.gblfy.flowable.config;import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseConnection;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.ui.common.service.exception.InternalServerErrorException;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Properties;/*** @ClassName ZhuangzProcessEngine* @Description TODO 构造流程引擎配置类* @Author gblfy* @Date 2019/11/17 20:12*/
@Configuration
public class GblfyProcessEngine {private static final Logger LOGGER = LoggerFactory.getLogger(GblfyProcessEngine.class);//TODO 解决创建流程时报act_re_model找不到protected static final String LIQUIBASE_CHANGELOG_PREFIX = "ACT_DE_";@Autowiredprivate DataSource dataSource;@Autowiredprotected ResourceLoader resourceLoader;//事务管理器@Beanpublic DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource){DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(dataSource);return dataSourceTransactionManager;}@Beanpublic SpringProcessEngineConfiguration springProcessEngineConfiguration(){SpringProcessEngineConfiguration springProcessEngineConfiguration =new SpringProcessEngineConfiguration();springProcessEngineConfiguration.setDataSource(dataSource);springProcessEngineConfiguration.setDatabaseSchemaUpdate("true");springProcessEngineConfiguration.setTransactionManager(dataSourceTransactionManager(dataSource));return springProcessEngineConfiguration;}@Beanpublic SqlSessionFactory sqlSessionFactory(DataSource dataSource) {SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();sqlSessionFactoryBean.setDataSource(dataSource);String databaseType = initDatabaseType(dataSource);if (databaseType == null) {throw new FlowableException("couldn't deduct database type");}try {Properties properties = new Properties();properties.put("prefix", "");properties.put("blobType", "BLOB");properties.put("boolValue", "TRUE");properties.load(this.getClass().getClassLoader().getResourceAsStream("properties/" + databaseType + ".properties"));sqlSessionFactoryBean.setConfigurationProperties(properties);sqlSessionFactoryBean.setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));sqlSessionFactoryBean.afterPropertiesSet();return sqlSessionFactoryBean.getObject();} catch (Exception e) {throw new FlowableException("Could not create sqlSessionFactory", e);}}protected String initDatabaseType(DataSource dataSource) {String databaseType = null;Connection connection = null;try {connection = dataSource.getConnection();DatabaseMetaData databaseMetaData = connection.getMetaData();String databaseProductName = databaseMetaData.getDatabaseProductName();LOGGER.info("database product name: '{}'", databaseProductName);databaseType = databaseTypeMappings.getProperty(databaseProductName);if (databaseType == null) {throw new FlowableException("couldn't deduct database type from database product name '" + databaseProductName + "'");}LOGGER.info("using database type: {}", databaseType);} catch (SQLException e) {LOGGER.error("Exception while initializing Database connection", e);} finally {try {if (connection != null) {connection.close();}} catch (SQLException e) {LOGGER.error("Exception while closing the Database connection", e);}}return databaseType;}protected static Properties databaseTypeMappings = getDefaultDatabaseTypeMappings();public static final String DATABASE_TYPE_MYSQL = "mysql";public static final String DATABASE_TYPE_ORACLE = "oracle";public static Properties getDefaultDatabaseTypeMappings() {Properties databaseTypeMappings = new Properties();databaseTypeMappings.setProperty("MySQL", DATABASE_TYPE_MYSQL);databaseTypeMappings.setProperty("Oracle", DATABASE_TYPE_ORACLE);return databaseTypeMappings;}@Beanpublic Liquibase liquibase(DataSource dataSource) {LOGGER.info("Configuring Liquibase");Liquibase liquibase = null;try {DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);//TODO 解决创建流程时报act_re_model找不到database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName());database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName());liquibase = new Liquibase("META-INF/liquibase/flowable-modeler-app-db-changelog.xml", new ClassLoaderResourceAccessor(), database);liquibase.update("flowable");return liquibase;} catch (Exception e) {throw new InternalServerErrorException("Error creating liquibase database", e);} finally {closeDatabase(liquibase);}}private void closeDatabase(Liquibase liquibase) {if (liquibase != null) {Database database = liquibase.getDatabase();if (database != null) {try {database.close();} catch (DatabaseException e) {LOGGER.warn("Error closing database", e);}}}}
}

五、启动类跳过登陆拦截

package com.gblfy.flowable;import org.flowable.ui.modeler.properties.FlowableModelerAppProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;/*** SpringBoot启动类** @Description跳过登陆拦截* @Author gblfy* @Date 2019/11/17 20:12*/
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@ComponentScan(basePackages = {"com.gblfy.flowable","org.flowable.ui.modeler","org.flowable.ui.common"})
public class FlowableApplication {public static void main(String[] args) {SpringApplication.run(FlowableApplication.class, args);}@Beanpublic FlowableModelerAppProperties flowableModelerAppProperties(){FlowableModelerAppProperties flowableModelerAppProperties = new FlowableModelerAppProperties();return flowableModelerAppProperties;}
}

六、配置文件

server:port: 80
spring:datasource:url: jdbc:mysql://localhost:3306/flowable_boot?zeroDateTimeBehavior=convertToNull&useUnicode=true&useSSL=false&rewriteBatchedStatements=truedriver-class-name: com.mysql.jdbc.Driverusername: rootpassword: roottype: com.alibaba.druid.pool.DruidDataSourceflowable:#关闭定时任务JOBasync-executor-activate: false将databaseSchemaUpdate设置为true。当Flowable发现库与数据库表结构不一致时,会自动将数据库表结构升级至新版本。database-schema-update: truecommon:app:idm-url: http://127.0.0.1://80/flowable-idm

项目源码下载:
https://gitee.com/gb_90/flow-modeler-sduty

SpringBoot集成flowable-modeler(6.4.1) 实现免登相关推荐

  1. Flowable6.5 之 springboot集成flowable modeler设计器

    源码 githup上下载老版本源码https://github.com/flowable/flowable-engine/releases gitHub:https://github.com/flow ...

  2. SpringBoot 集成Flowable设计器(Flowable-ui)

    一.项目场景: 提示:使用版本6.7.0 公司使用前后端项目分离,前端使用bpmn插件生成bpmn xml文件,后端解析处理数据.今天主要介绍后端集成flowable设计器的过程中遇到的问题. 如需了 ...

  3. springboot集成flowable创建请假流程实例

    springboot如何集成flowable,如何部署flowable在线编辑器画bpm图以及bpm图的画法,我在上一篇博客中写了,这里直接上代码(源码地址:晚安/flowable_holiday ( ...

  4. springboot和flowable modeler整合

    准备:项目使用的是springboot2.1.5版本,flowable6.4.0版本 1. IDEA新建Spring Initializr项目,选择依赖,web和MySQL 2. 修改pom.xml依 ...

  5. SpringBoot集成Flowable

    一.项目结构 二.maven配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns= ...

  6. springboot集成flowable简单实例入门

    此案例是demo.功能有创建流程.完成审批.生成流程图.适合有java基础的人员看. 第一步.画流程图 resources资源包下,新建processes包,新建一个文件,我命名他apply-rest ...

  7. springboot2.0集成activiti modeler

    项目采用Springboot 2.0.3.RELEASE版本以及activiti 5.22.0版本 在acitiviti官网下载完整包https://github.com/Activiti/Activ ...

  8. flowable springboot 集成 flowableDMN_05

    文章目录 配置POM 配置Config 通过上述的配置,现在在spring容器中已经存在一些接口bean了 项目地址:https://gitee.com/lwj/flowable.git 分支flow ...

  9. springboot+vue 审批工作流集成flowable(springboot实现工作流)

    仿钉钉审批流程图在线绘制.业务申请.审批.流转.委托.催办,springboot集成工作流基础框架 前言 目前市场上有很多开源平台没有整合工作流,即使有,也是价格不菲的商业版,这次推荐的是在一个基础开 ...

  10. Activiti 快速入门教程:SpringBoot 集成 Activiti6 + Activiti Modeler 流程配置可视化

    Activiti 快速入门教程:SpringBoot 集成 Activiti6 + Activiti Modeler 流程配置可视化 7大服务与核心表 23张表概览 7大核心服务(重要) 加依赖 内部 ...

最新文章

  1. Java中变量、类初始化顺序
  2. php 获取文件后缀_php获取文件后缀的9种方法
  3. 使用Schematics启用SAP Spartacus的SSR模式
  4. 2019-03-28 SQL Server Pivot
  5. centos6.5安装配置zabbix3.0.3
  6. 设置eclipse的Maven插件引入依赖jar包后自动下载并关联相应的源码(转)
  7. 局部加权线性回归,线性回归高级版
  8. 10种提高WordPress访问速度的方法
  9. html文件夹加密,HTML加密转换工具(WebCrypt)
  10. 知识图谱 helloword
  11. 计算机其它离的360云盘,360云盘资源转到百度云 360云盘搬家教程
  12. Eclipse下jsp模板设置
  13. 计算机图形学 | 实验四:绘制一个球体
  14. 【转】增强型、耗尽型MOS
  15. Query类常用参数详解
  16. 青年男女的爱情宝典(未婚必看)
  17. 【美团点评2020校招测试方向笔试题】算法题部分1.删除字符 2.队列组合排序 3.寻找最小子字符串 4.最大矩形 5.最短送餐路程计算
  18. 【MMD】个人记录向
  19. WordPress添加plugin
  20. Vue项目打包步骤详细流程,新手必需掌握的知识点!

热门文章

  1. linux内核态获取ip地址,Linux内核支持动态获取IP地址
  2. IO之 Properties类加载文件
  3. sdut 数字三角形问题
  4. cuda nsight 调试和性能分析
  5. 终端卡顿优化的全记录
  6. 重磅官宣:Nacos2.0发布,性能提升10倍
  7. 阿里云AHAS Chaos:应用及业务高可用提升工具平台之故障演练
  8. 如何优雅地在云上“摆摊” 直播带货,这些技术很重要
  9. 数据库OceanBase创始人阳振坤:通关TPC-C到底有多难?
  10. 在 Kubernetes 集群中使用 MetalLB 作为 LoadBalancer(下)