基本配置参考
详见:链接: flowable快速实现
调试报错信息
<!--审批流相关依赖-->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<!--<version>1.0.2</version>-->
<!--<exclusions>
<exclusion>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
</exclusion>
</exclusions>-->
</dependency>
启动报错
1、‘javax.persistence.EntityManagerFactory’ that could not be found
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
Disconnected from the target VM, address: ‘127.0.0.1:55621’, transport: ‘socket’
2022-12-09 14:41:27.029 ERROR 44920 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 0 of method jpaProcessEngineConfigurer in org.flowable.spring.boot.FlowableTransactionAutoConfiguration$JpaTransactionConfiguration required a bean of type ‘javax.persistence.EntityManagerFactory’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘javax.persistence.EntityManagerFactory’ in your configuration.
Process finished with exit code 1
解决:初始化表,操作数据库使用jpa,我们这里解决办法就是引入spring-data-jpa-starter自动配置EntityManagerFactory。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
2、出现了依赖版本冲突的问题persistence-api 包含一个1.0和2.2,根据提示我们选择使用1.0
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location: org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor.getValidationMode(PersistenceUnitInfoDescriptor.java:88)The following method did not exist: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;The method’s class, javax.persistence.spi.PersistenceUnitInfo, is available from the following locations: jar:file:/D:/Program%20Files/apache-maven-3.6.0/localRepository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/javax/persistence/spi/PersistenceUnitInfo.class jar:file:/D:/Program%20Files/apache-maven-3.6.0/localRepository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar!/javax/persistence/spi/PersistenceUnitInfo.classIt was loaded from the following location: file:/D:/Program%20Files/apache-maven-3.6.0/localRepository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.spi.PersistenceUnitInfo
解决:找到冲突的包然后如果是之前引用,但实际不起作用的包则注释掉其中一个;或者在pom文件里面我们直接依赖1.0版本,maven会选择直接依赖,解决其他间接依赖的版本冲突。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.0</version>
</dependency>
3、no processes deployed with key ‘xxx’
org.activiti.engine.ActivitiObjectNotFoundException: no processes deployed with key ‘myProcess_11’
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedLatestProcessDefinitionByKey(DeploymentManager.java:85)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:85)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:37)
at org.activiti.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:37)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:78)
at org.activiti.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:57)
解决:
1.xml文件的id和你启动的key不一致
2.activiti 的模版必须以 bpmn20.xml 或者 bpmn结尾。
在processes文件夹下的xml要与 flowable的配置一致,
并且 select * from act_re_procdef;
在这张表中找到对应的key,再启动流程,如果没有,证明部署流程定义失败。
注意事项
flowable建议采用业界标准BPMN2.0的XML来描述需要定义的工作流。
resources 下的流程定义文件 要与配置中保持一致
流程图乱码问题。
可参考: 前段展示流程图中文说明 框框