逆向剖析偏向第二篇

Flowable与springBoot项目整合及泛起的问题

单纯地将Flowable和springBoot整合,使用mysql作为数据库,整合中踩了两个坑,见文末。
在pom中添加依赖



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.2.0.RELEASE
         
    
    com.happen
    flowable1
    0.0.1-SNAPSHOT
    flowable1
    Demo project for Spring Boot
    
        1.8
    
    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
        
            org.flowable
            flowable-spring-boot-starter
            6.6.0
        


        
            mysql
            mysql-connector-java
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


application.yml文件
database-schema-update: true的作用是自动更新数据库中需要的表,在第一次运行时需要

server:
  port: 8000

web:
  domain: http://localhost

spring:
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    username: root
    password: WHP199617whp
    url: jdbc:mysql://localhost:3306/flowable1?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true

flowable:
  async-executor-activate: false
  database-schema-update: true

Flowable1Application
对数据库中的流程数目举行查询

MySQL提升条记(3)日志文件详解

package com.happen.flowable1;

import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication(proxyBeanMethods = false)
public class Flowable1Application {

    public static void main(String[] args) {
        SpringApplication.run(Flowable1Application.class, args);
    }

    @Bean
    public CommandLineRunner init(final RepositoryService repositoryService,
                                  final RuntimeService runtimeService,
                                  final TaskService taskService) {

        return new CommandLineRunner() {
            @Override
            public void run(String... strings) throws Exception {
                System.out.println("Number of process definitions : "
                        + repositoryService.createProcessDefinitionQuery().count());
                System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
                runtimeService.startProcessInstanceByKey("oneTaskProcess");
                System.out.println("Number of tasks after process start: "
                        + taskService.createTaskQuery().count());
            }
        };
    }
}

xml文件,这是一个 BPMN 2.0的尺度文件




    
        
        
        
        
        
    


完整的项目目录如下:

运行效果

会在数据库中天生对应的表

控制台中:

遇到的坑

  1. 建表的时刻泛起 table 'flowable1.act_id_user' doesn't exist
    这是由于之前本机上建过相同的表,现在不许重复建表了?在数据库设置时后面追加&nullCatalogMeansCurrent=true即可
  2. nested exception is org.flowable.common.engine.api.FlowableException: Error initialising eventregistry data model
    将springboot版本设置为2.2.0.RELEASE即可(我试了2.4.5就是不行,真坑,不行就删了数据库中的所有表再试试)。

python基础(弥补):lambda匿名函数,用了的,都说好!

标签: none

评论已关闭