一、Spring Boot整合Flowable UI Modeler 6.7.2

在若依项目中创建基础模块,按照Spring Boot整合Flowable UI Modeler 6.7.2,可以参考上一篇文章,文章地址如下:

Spring Boot 整合 Flowable-ui-modeler 6.7.2_wangdaoyin2010的博客-CSDN博客

二、修改数据库配置

按照Spring Boot方式整合Modeler后,在flowable-ui-modeler-conf依赖中类ModelerDatabaseConfiguration中注入了SqlSessionFactory和SqlSessionTemplate数据库相关Bean。这些注入的Bean会与ruoyi中的MyBatis自动注入的会冲突。所以需要需要重写flowable-ui-modeler-conf中的ModelerDatabaseConfiguration类中对应响应的配置进行重写。

1、覆盖ModelerDatabaseConfiguration

床建ModelerDatabaseConfiguration类,覆盖flowable-ui-modeler-conf依赖中的该类。


@Configuration(proxyBeanMethods = false)
public class ModelerDatabaseConfiguration {private static final Logger LOGGER = LoggerFactory.getLogger(ModelerDatabaseConfiguration.class);protected static final String LIQUIBASE_CHANGELOG_PREFIX = "ACT_DE_";@Autowiredprotected FlowableModelerAppProperties modelerAppProperties;@Autowiredprotected MybatisProperties mybatisProperties;@Autowiredprotected ResourceLoader resourceLoader;protected static Properties databaseTypeMappings = getDefaultDatabaseTypeMappings();public static final String DATABASE_TYPE_H2 = "h2";public static final String DATABASE_TYPE_HSQL = "hsql";public static final String DATABASE_TYPE_MYSQL = "mysql";public static final String DATABASE_TYPE_ORACLE = "oracle";public static final String DATABASE_TYPE_POSTGRES = "postgres";public static final String DATABASE_TYPE_MSSQL = "mssql";public static final String DATABASE_TYPE_DB2 = "db2";public static Properties getDefaultDatabaseTypeMappings() {Properties databaseTypeMappings = new Properties();databaseTypeMappings.setProperty("H2", DATABASE_TYPE_H2);databaseTypeMappings.setProperty("HSQL Database Engine", DATABASE_TYPE_HSQL);databaseTypeMappings.setProperty("MySQL", DATABASE_TYPE_MYSQL);databaseTypeMappings.setProperty("MariaDB", DATABASE_TYPE_MYSQL);databaseTypeMappings.setProperty("Oracle", DATABASE_TYPE_ORACLE);databaseTypeMappings.setProperty("PostgreSQL", DATABASE_TYPE_POSTGRES);databaseTypeMappings.setProperty("Microsoft SQL Server", DATABASE_TYPE_MSSQL);databaseTypeMappings.setProperty(DATABASE_TYPE_DB2, DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/NT", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/NT64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2 UDP", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUX", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUX390", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUXX8664", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUXZ64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUXPPC64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/LINUXPPC64LE", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/400 SQL", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/6000", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2 UDB iSeries", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/AIX64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/HPUX", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/HP64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/SUN", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/SUN64", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2);databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2);return databaseTypeMappings;}@Bean@Qualifier("flowableModeler")@Primarypublic SqlSessionFactory modelerSqlSessionFactory(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", modelerAppProperties.getDataSourcePrefix());properties.put("blobType", "BLOB");properties.put("boolValue", "TRUE");properties.load(this.getClass().getClassLoader().getResourceAsStream("org/flowable/db/properties/" + databaseType + ".properties"));sqlSessionFactoryBean.setConfigurationProperties(properties);//这个是原始代码,只添加flowable的扫描路径
//            sqlSessionFactoryBean
//                    .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));//由于后面要设置该SqlSessionFactory为主要的SqlSessionFactory,// 然后Ruoyi中使用时Mybatis自动注入,所以在这个地方就需要添加Ruoyi配置扫描ResourcePatternResolver resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);List<Resource> allResourceList = new ArrayList<>();List<String> mapperLocations = new ArrayList<>();//先添加mapperLocations.add("classpath:/META-INF/modeler-mybatis-mappings/*.xml");mapperLocations.add("classpath*:/mapper/**/*Mapper.xml");for (String mapperLocation : mapperLocations) {try {Resource[] resources = resourcePatternResolver.getResources(mapperLocation);allResourceList.addAll(Arrays.asList(resources));} catch (Exception ex) {throw new FlowableException("Could not create sqlSessionFactory", ex);}}Resource[] allResourceArr = allResourceList.toArray(new Resource[allResourceList.size()]);//因为若依中使用了类别名基础包,所以需要在这个地方进行添加sqlSessionFactoryBean.setTypeAliasesPackage(mybatisProperties.getTypeAliasesPackage());sqlSessionFactoryBean.setMapperLocations(allResourceArr);sqlSessionFactoryBean.afterPropertiesSet();return sqlSessionFactoryBean.getObject();} catch (Exception e) {throw new FlowableException("Could not create sqlSessionFactory", e);}}@Bean(destroyMethod = "clearCache")// destroyMethod: see https://github.com/mybatis/old-google-code-issues/issues/778@Qualifier("flowableModeler")@Primarypublic SqlSessionTemplate modelerSqlSessionTemplate(@Qualifier("flowableModeler") SqlSessionFactory sqlSessionFactory) {return new SqlSessionTemplate(sqlSessionFactory);}@Bean@Qualifier("flowableModeler")public Liquibase modelerLiquibase(DataSource dataSource) {LOGGER.info("Configuring Liquibase");try {return LiquibaseUtil.runInFlowableScope(() -> createAndUpdateLiquibase(dataSource));} catch (Exception e) {throw new InternalServerErrorException("Error creating liquibase database", e);}}protected Liquibase createAndUpdateLiquibase(DataSource dataSource) {Liquibase liquibase = null;try {DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);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);}}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;}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);}}}}}

2、添加注解@Primary

由于flowable-ui-modeler-rest中对SqlSessionTemplate和SqlSessionFactory注入添加了@Qualifier("flowableModeler"),所以不能通过只保留Mybatis自动注入的Bean。所以在这两个Bean注入的地方添加@Primary,让MyBatis自动注入的时候使用这个地方生成的bean,就不会报两个Bean不知道怎么选的错误。

Flowable-logic中对SqlSessionTemplate和SqlSessionFactory的注入代码如下

@Component
public class ModelHistoryRepositoryImpl implements ModelHistoryRepository {private static final String NAMESPACE = "org.flowable.ui.modeler.domain.ModelHistory.";@Autowired@Qualifier("flowableModeler")protected SqlSessionTemplate sqlSessionTemplate;
}@Component
public class ModelRelationRepositoryImpl implements ModelRelationRepository {private static final String NAMESPACE = "org.flowable.ui.modeler.domain.ModelRelation.";@Autowired@Qualifier("flowableModeler")protected SqlSessionTemplate sqlSessionTemplate;
}
@Component
public class ModelRepositoryImpl implements ModelRepository {private static final String NAMESPACE = "org.flowable.ui.modeler.domain.Model.";@Autowired@Qualifier("flowableModeler")protected SqlSessionTemplate sqlSessionTemplate;
}

3、配置SqlSessionFactory提价ruoyi中mapper扫描

由于使用了该类中创建的SqlSessionFactory,所以需要将ruoyi中的mapper添加到该工厂下进行扫描。ruoyi中Mapper可以参考nacos数据库配置,配置如下

# mybatis配置
mybatis:# 搜索指定包别名typeAliasesPackage: com.ruoyi.system# 配置mapper的扫描,找到所有的mapper.xml映射文件mapperLocations: classpath:mapper/**/*.xml

注意:在添加扫描路径的时候,需要搜索指定包别名

具体修改代码如下

  sqlSessionFactoryBean.setConfigurationProperties(properties);//这个是原始代码,只添加flowable的扫描路径
//            sqlSessionFactoryBean
//                    .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));//由于后面要设置该SqlSessionFactory为主要的SqlSessionFactory,// 然后Ruoyi中使用时Mybatis自动注入,所以在这个地方就需要添加Ruoyi配置扫描ResourcePatternResolver resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);List<Resource> allResourceList = new ArrayList<>();List<String> mapperLocations = new ArrayList<>();//先添加mapperLocations.add("classpath:/META-INF/modeler-mybatis-mappings/*.xml");mapperLocations.add("classpath*:/mapper/**/*Mapper.xml");for (String mapperLocation : mapperLocations) {try {Resource[] resources = resourcePatternResolver.getResources(mapperLocation);allResourceList.addAll(Arrays.asList(resources));} catch (Exception ex) {throw new FlowableException("Could not create sqlSessionFactory", ex);}}Resource[] allResourceArr = allResourceList.toArray(new Resource[allResourceList.size()]);//因为若依中使用了类别名基础包,所以需要在这个地方进行添加sqlSessionFactoryBean.setTypeAliasesPackage(mybatisProperties.getTypeAliasesPackage());sqlSessionFactoryBean.setMapperLocations(allResourceArr);sqlSessionFactoryBean.afterPropertiesSet();return sqlSessionFactoryBean.getObject();

三、添加自动配置

1、添加自动配置类

由于在自己创建的子模块中添加了SecurityConfiguration安全配置类,然后该子模块要被其他模块进行依赖添加,所以需要添加自动配置类来扫描到自己添加的安全配置类

@Configuration
//这个地方通过配置扫描包的方式让SecurityConfiguration能被扫描到
//以后在该包下添加的类也会自动被扫描
@ComponentScan("com.ruoyi.flowable.modeler")
public class RuoyiFlowableModelerAutoConfiguration {}

2、添加spring.factories文件

要在引用该模块时能完成该模块中的自动配置,需要添加spring.factories。在resources目录下创建META-INF文件夹,在该文件夹下创建spring.factories文件。

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\com.ruoyi.flowable.modeler.config.RuoyiFlowableModelerAutoConfiguration

四、测试

在ruoyi-system中添加前面子模块的依赖,然后启动ruoyi-system模块。然后在浏览器中浏览http://localhost:9201/modeler得到如下如图标识添加Modeler成功

到此Ruoyi集成Flowable UI Modeler成功

Ruoyi 整合Flowable UI Modeler 6.7.2相关推荐

  1. MybatisPlus整合Flowable出现的坑

    MybatisPlus整合Flowable出现的坑 - 摘要:现在在项目中使用的MybatisPlus,最近研究了一下流程框架Flowable,看了很多技术文档博客,打算直接整合进去,先记录一下遇到的 ...

  2. [ Flowable ] 与modeler流程设计器整合教程

    Flowable 与 modeler 流程设计器整合方案 本教程基于Flowable 6.2.1 ,破解 flowable-idm的权限登录,整合SpringMVC实现maven动态导入jar包,期间 ...

  3. Flowable工作流之Flowable UI画工作流程图

    目录 1. `Flowable` 简介 2. 绘制工作流程图 2.1. `Flowable UI` 的安装部署 2.2. 启动服务 2.3. 用户管理 2.4. 工作流程效果图 2.5. 绘制工作流程 ...

  4. Flowable UI制作流程图

    使用Flowable UI创建流程 Flowable UI提供了几个web应用,用于演示及介绍Flowable项目提供的功能: Flowable IDM: 身份管理应用.为所有Flowable UI应 ...

  5. webpack整合 vue-router 路由,模块嵌套,整合Mint UI,MUI

    webpack整合 vue-router 结构 各个文件内容,一共八个文件, 还有src components 目录 Login.vue <template><div>< ...

  6. Springboot整合Swagger UI 3.0.0 版本

    一.前言 在之前的项目中,以及提到了如何整合 Swagger UI 2 版本,包括导入jar包,编写配置文件,以及需要对应的springboot版本等. 链接如下:https://blog.csdn. ...

  7. springboot整合flowable

    一 官方提供的war包 从flowable.org网站下载.zip文件后,可以在wars目录下找到REST应用.要运行这个WAR文件,需要一个servlet容器,例如Tomcat.Jetty等. 使用 ...

  8. 若依RuoYi整合短信验证码登录

    背景:若依默认使用账号密码进行登录,但是咱们客户需要增加一个短信登录功能,即在不更改原有账号密码登录的基础上,整合短信验证码登录. 一.自定义短信登录 token 验证 仿照 UsernamePass ...

  9. springboot整合flowable(mysql)第一节

    开发工具:Intellij idea 目录 1. 新建maven项目 2. 修改pom文件 3. 建库 4. 配置文件 5. 启动程序 6. 添加日志依赖 1. 新建maven项目 上图中spring ...

  10. SpringBoot整合Flowable工作流引擎框架

    Flowable工作流引擎框架介绍 一个Java编写的轻量级业务流程引擎,为开发人员.系统管理员和业务用户提供工作流和业务流程管理(BPM)平台. 不仅包括BPMN,还有DMN决策表和CMMN Cas ...

最新文章

  1. Go Mvc的一个示例
  2. Nvidia黄仁勋发布了全球最大GPU
  3. 民族、学历学位、所学专业、、专业技术职务 对应表
  4. python免费试听-小栈春季编程免费试听课 倒数6天!
  5. oracle中的char和j,oracle中char与varchar2的区别
  6. 正则 禁止连续逗号_正则
  7. underscore源码剖析之整体架构
  8. 对Vue生命周期的一些简单见解
  9. 【自由随想录(三)】
  10. windows系统: 解决ie谷歌浏览器证书错误.2021-05-27
  11. 彻底理解Linux的各种终端类型以及概念
  12. Spanning Tree协议安全攻防
  13. tensorflow离线安装
  14. Maya快捷键、拆UV、上材质
  15. 配置webpack不打包第三方包
  16. php考核奖金制度,奖金制度与绩效考核
  17. JVM原理讲解和调优
  18. 计算机视觉最新进展概览2021年10月18日到2021年10月23日
  19. 步进电机H桥驱动电路设计 【转】
  20. Flink DataStream Connectors 之 Apache Kafka 连接器

热门文章

  1. 关于junk jack
  2. take their time用法
  3. 基于深度学习的检测和阶段分级优化糖尿病视网膜病变的诊断
  4. 只因写了一段爬虫,公司200多人被抓!
  5. 浏览器标准模式和怪异模式之间的区别是什么——整理自网页
  6. Duplicate entry '127' for key 'PRIMARY'
  7. IOS10上崩溃错误“View has lost track of its superview, most likely through unsupported use of CALayer”解决方案
  8. python12306抢票_GitHub - versionzhang/python_12306: python 12306 抢票工具
  9. php 遍历文件夹并压成zip_将文件夹压缩成zip文件的php代码
  10. 关于建站、服务器、云虚拟主机你想知道的都在这里!