Flowable学习笔记(一):SpringBoot项目整合Flowable

1.基于k8s部署Mysql

参考:k8s部署mysql

我安装是去掉了卷挂载。安装过程可能出现磁盘容量不够,可以通过df -h查看。
在这里插入图片描述
镜像下载得比较慢,可以先用docker拉取镜像。
在这里插入图片描述在这里插入图片描述

2.搭建SpringBoot项目

(1)搭建maven项目,pom.xml依赖如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.12.RELEASE</version>
</parent>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <flowable.version>6.7.2</flowable.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <!-- MYSQL -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

(2)配置文件 application.yaml

spring:
  datasource:
    password: root
    username: root
    url: jdbc:mysql://x.x.x.x:31090/flowable?useUnicode=true;characterEncoding=UTF-8
    driver-class-name: com.mysql.cj.jdbc.Driver

(3)启动类

package gdut;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication(proxyBeanMethods = false)
@ComponentScan("gdut.**")
public class FlowableApplication {

    public static void main(String[] args) {
        SpringApplication.run(FlowableApplication.class, args);
    }
}
3.整合flowable

参考:flowable官方文档

添加flowable的spring boot依赖,版本是6.7.2。

<dependency>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-spring-boot-starter</artifactId>
    <version>${flowable.version}</version>
</dependency>

启动启动类。数据库flowable自动创建了flowable的数据库表。
在这里插入图片描述

4.部署流程定义

划重点:流程定义文件需要以.bpmn20.xml结尾,不然流程定义部署会不生效。

//部署流程定义
Deployment deployment = processEngine.getRepositoryService().createDeployment()
        .addClasspathResource("test.bpmn20.xml")
        .name("oneTaskProcess")
        .deploy();
        
//查询流程定义        
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
        .deploymentId(deployment.getId())
        .singleResult();
System.out.println("Found process definition : " + processDefinition.getName());

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());
5.flowable-ui

我使用的flowable-ui版本是6.7.2。

参考文档:flowable+tomcat部署flowable项目,在线画流程图

flowable-ui.war解压后,在WEB-INF/classes文件夹下有一个flowable-default.properties文件。我修改了数据库的驱动,默认是h2,我修改为mysql,没有额外增加jar包。数据库连接地址修改为我上面创建的mysql。
在这里插入图片描述
在这里插入图片描述
登录效果:
在这里插入图片描述

参考文档

(1)出现以下问题,可能是k8s卷挂载的问题,可以把卷挂载去掉。不影响mysql使用。
在这里插入图片描述
解决方案参考:mysqld: Can‘t read dir of ‘/etc/mysql/conf.d/‘ (Errcode: 2 - No such file or directory

(2)数据库客户端Navicat无法连接数据库
连接MySQL数据库出现错误:2059 - authentication plugin ‘caching_sha2_password‘的解决方法

(3)springboot Flowable集成 Error creating bean with name ‘flowableAppEngine‘ flowableException

(4)流程定义文件必须要以.bpmn20.xml结尾

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值