flowable集成springboot

公司工作需要,需要学习flowable流程引擎,本文章为flowable中文手册5.7集成springboot步骤

1.开始

使用idea创建一个springboot项目,然后根据手册添加flowable依赖

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

然后直接运行启动类,会得到异常提示

image-20211102135817740

指出需要在pom文件中添加数据库驱动依赖,添加H2数据库依赖:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.3.176</version>
</dependency>

此时项目依赖为:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.flowable</groupId>
        <artifactId>flowable-spring-boot-starter</artifactId>
        <version>${flowable.version}</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.176</version>
    </dependency>
</dependencies>

启动,输出为:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d9ih0zgQ-1635904405028)(C:\Users\win\AppData\Roaming\Typora\typora-user-images\image-20211102140117167.png)]

2.添加配置文件

在resources目录下,创建processes目录,在processes目录下创建one-task-process.bpmn20.xml文件(注意文件名不要出错)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Tpuc8QXi-1635904405034)(C:\Users\win\AppData\Roaming\Typora\typora-user-images\image-20211102140520093.png)]

one-task-process.bpmn20.xml

<?xml version="1.0" encoding="UTF-8"?>
<definitions
        xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
        xmlns:flowable="http://flowable.org/bpmn"
        targetNamespace="Examples">
    <process id="oneTaskProcess" name="The One Task Process">
        <startEvent id="theStart"/>
        <sequenceFlow id="flow1" sourceRef="theStart"
                      targetRef="theTask"/>
        <userTask id="theTask" name="my task"/>
        <sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd"
        />
        <endEvent id="theEnd"/>
    </process>
</definitions>

然后启动类添加下列代码,以测试部署是否生效。CommandLineRunner是一个特殊的Spring bean,在应用启动时执行:

SpringbootApplication.java

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
public class SpringbootApplication {
   

    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值