flowable集成springboot

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

1.开始

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

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

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

image-20211102135817740

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

<dependency>
    <groupId>com.h2databasegroupId>
    <artifactId>h2artifactId>
    <version>1.3.176version>
dependency>

此时项目依赖为:

<dependencies>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starterartifactId>
    dependency>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-testartifactId>
        <scope>testscope>
    dependency>
    <dependency>
        <groupId>org.flowablegroupId>
        <artifactId>flowable-spring-boot-starterartifactId>
        <version>${flowable.version}version>
    dependency>
    <dependency>
        <groupId>com.h2databasegroupId>
        <artifactId>h2artifactId>
        <version>1.3.176version>
    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


<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 {
   

    pub

你可能感兴趣的:(flowable,spring,boot,intellij-idea,java)