文章目录

  • 前言
  • 一、 新建一个spring boot 项目
  • 二、 配置项目
  • 1、在pom文件中导入依赖(主要依赖)
  • 2、application.properties 配置文件
  • 三、启动项目
  • 错误一、切换 H2 数据库为 MySQL 数据库,启动项目遇到一个错误
  • 错误二、更换 flowable 版本需要修改数据库
  • 错误三、mysql连接版本问题


前言

刚刚接触 flowable,以下以 flowable 中文文档入门实践,如有错误还望指出

flowable 中文文档地址
https://tkjohn.github.io/flowable-userguide/#_introduction

一、 新建一个spring boot 项目
二、 配置项目
1、在pom文件中导入依赖(主要依赖)
<!--MySQL依赖 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.45</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter</artifactId>
            <version>${flowable.version}</version>
        </dependency>
2、application.properties 配置文件
server.port=6666
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/flowable?characterEncoding=UTF-8&nullCatalogMeansCurrent=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
三、启动项目
错误一、切换 H2 数据库为 MySQL 数据库,启动项目遇到一个错误

springboot项目整合 Finereport8 springboot整合flowable_flowable


在数据库配置 url 中加入 nullCatalogMeansCurrent=true,上面的 application.properties 配置文件已经添加过了

注意:我的数据库 5.7,如果你的数据库 8.0及以上,可以不加
可以参考博客 有详细解释

错误二、更换 flowable 版本需要修改数据库
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appRepositoryServiceBean' defined in class path resource [org/flowable/spring/boot/app/AppEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'appRepositoryServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Could not update Flowable database schema: unknown version from database: '6.6.0.0'

原因:更换最新 flowable 版本,导致数据库冲突
解决方法
一、暴力解决 清空数据库表(不建议)
二、打开本地数据库,修改如下两个表,根据你的项目版本改

ACT_ID_PROPERTY

springboot项目整合 Finereport8 springboot整合flowable_mysql_02


ACT_GE_PROPERTY

springboot项目整合 Finereport8 springboot整合flowable_spring boot_03


参考如下博客

错误三、mysql连接版本问题

按照 flowable 文档添加如下部分代码以及文件

springboot项目整合 Finereport8 springboot整合flowable_mysql_04


没有达到预期效果,出现错误如下(日志太长了,删除了部分)

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'init' defined in com.sgcc.flowabletest.MyFowableApplication: Unsatisfied dependency expressed through method 'init' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositoryServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'repositoryServiceBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration$AlreadyInitializedAppEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) [spring-boot-2.4.4.jar:2.4.4]
	at com.sgcc.flowabletest.MyFowableApplication.main(MyFowableApplication.java:15) [classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositoryServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'repositoryServiceBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration$AlreadyInitializedAppEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.5.jar:5.3.5]
	... 20 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processEngine' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration$AlreadyInitializedAppEngineConfiguration.class]: Unsatisfied dependency expressed through method 'processEngine' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.5.jar:5.3.5]
	... 34 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowableAppEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:176) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1884) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1266) ~[spring-beans-5.3.5.jar:5.3.5]
	org.flowable.app.spring.AppEngineFactoryBean.getObject(AppEngineFactoryBean.java:31) ~[flowable-app-engine-spring-6.4.0.jar:6.4.0]
	org.flowable.dmn.engine.impl.db.DmnDbSchemaManager.initSchema(DmnDbSchemaManager.java:61) ~[flowable-dmn-engine-6.4.0.jar:6.4.0]
	... 82 common frames omitted

错误原因
更换 jdbc依赖版本,之前我的依赖如下,没有写版本号,默认导入 8.0.23 版本
pom.xml文件

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

下载的包

springboot项目整合 Finereport8 springboot整合flowable_java_05


解决办法

使用 5.1.45 版本成功,支持什么那些版本我没有去查,测试了几个都用不了,不知道是否和本地数据库有关,希望知道了留言说一下

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.45</version>
        </dependency>

报了一个警告,可以在数据库url配置后面添加属性useSSL=false,关闭SSL连接

Thu Apr 08 20:09:53 CST 2021 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

程序正常运行,达到预期结果

springboot项目整合 Finereport8 springboot整合flowable_mysql_06


完结撒花,虽然项目很简单,啥也没有,报的错还挺多的,之后深入了解了,再写博客分享。