springboot整合flowable快速实现工作流

1 flowable-ui部署运行

从官网下载flowable-6.6.0 :

https://github.com/flowable/flowable-engine/releases/download/flowable-6.7.2/flowable-6.7.2.zip

 将压缩包中的 flowable-6.7.2\wars\下的两个war包丢到Tomcat中的webapps文件夹中

 进入bin目录,启动tomcat 

cd D:\apps\apache-tomcat-8.5.75\bin 

 startup.bat命令启动tomcat

【tomcat8出现控制台乱码】

【解决】 

打开regedit,进入HKEY_CURRENT_USER\Console\Tomcat,如果没有Tomcat则新建。然后按照下图新建CodePage项

 重启tomcat,控制台出现中文,没有乱码

配置连接本地数据库

 进入apache-tomcat-8.5.75\webapps\flowable-ui\WEB-INF\classes\flowable-default.properties

连接本地数据库

把mysql驱动放在apache-tomcat-8.5.75\webapps\flowable-rest\WEB-INF\lib路径下

给apache-tomcat-8.5.75\webapps\flowable-ui\WEB-INF\lib路径下也放一个驱动

再重启tomcat,成功启动

 访问flowable-ui本地登录页面

登录账号 admin  密码  test 

 登录成功后

 点击”建模器应用程序“进行流程创建

 

开始模仿着画一个流程图

 上图是一个完整的流程图,我们仿照着画一下

 点击圆圈,开始用户任务

 点击网关,到底是同意还是拒绝

 开始或结束

 把每一个节点的信息在下面定义清楚

画拒绝时,回到学生节点  美化箭头

 画出了两个拒绝节点

 保存并下载工作流文件

 

 这是下载的 "请假流程.bpmn20.xml"文件中的内容

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef" exporter="Flowable Open Source Modeler" exporterVersion="6.7.2">
  <process id="leave" name="请假流程" isExecutable="true">
    <documentation>这是一个企业里请假的业务流程</documentation>
    <startEvent id="startEvent1" name="开始" flowable:formFieldValidation="true"></startEvent>
    <userTask id="stu_id" name="学生" flowable:assignee="student1" flowable:candidateUsers="student2" flowable:candidateGroups="student3" flowable:formFieldValidation="true">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <userTask id="tea_id" name="老师" flowable:assignee="teacher1" flowable:candidateUsers="teacher2" flowable:candidateGroups="teacher3" flowable:formFieldValidation="true">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="sid-CD407403-63C0-4B4D-BB3F-A7AA0A6FC179"></exclusiveGateway>
    <userTask id="sch_id" name="校长" flowable:assignee="school1" flowable:candidateUsers="school2" flowable:candidateGroups="school3" flowable:formFieldValidation="true">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="sid-C31293B4-7562-480A-AF71-39E49828EB01"></exclusiveGateway>
    <sequenceFlow id="leave_id" name="请假" sourceRef="stu_id" targetRef="tea_id"></sequenceFlow>
    <sequenceFlow id="sid-4B42339A-6241-4D08-B75B-988421C4A6DB" sourceRef="startEvent1" targetRef="stu_id"></sequenceFlow>
    <sequenceFlow id="tea_agree_id" name="同意" sourceRef="sid-CD407403-63C0-4B4D-BB3F-A7AA0A6FC179" targetRef="sch_id"></sequenceFlow>
    <sequenceFlow id="tea_deny_id" name="拒绝" sourceRef="sid-CD407403-63C0-4B4D-BB3F-A7AA0A6FC179" targetRef="stu_id"></sequenceFlow>
    <sequenceFlow id="sch_apply_id" name="审批" sourceRef="sch_id" targetRef="sid-C31293B4-7562-480A-AF71-39E49828EB01"></sequenceFlow>
    <sequenceFlow id="tea_apply_id" name="审批" sourceRef="tea_id" targetRef="sid-CD407403-63C0-4B4D-BB3F-A7AA0A6FC179"></sequenceFlow>
    <sequenceFlow id="sch_deny_id" name="拒绝" sourceRef="sid-C31293B4-7562-480A-AF71-39E49828EB01" targetRef="stu_id"></sequenceFlow>
    <endEvent id="end_id" name="结束"></endEvent>
    <sequenceFlow id="sch_agree_id" name="同意" sourceRef="sid-C31293B4-7562-480A-AF71-39E49828EB01" targetRef="end_id"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_leave">

    这里的代码暂时没用,先删掉
  </bpmndi:BPMNDiagram>
</definitions>

 把生成的xml文件放在springboot的reources下

2 springboot集成flowable

引入pom

<!-- 工作流 -->
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter</artifactId>
            <version>6.7.2</version>
        </dependency>
        <!--Mysql数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- druid -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.8</version>
        </dependency>
        <!--mybatis-plus依赖-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>
        <!--分页插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.1</version>
            <!--去除内置的mybatis,防止和mybatis-plus冲突-->
            <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis-spring</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

配置application.properties

#serverPort
server.port=9001

#datasource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/flowable_master?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.druid.initialSize=5
spring.datasource.druid.minIdle=5
spring.datasource.druid.maxActive=20
spring.datasource.druid.maxWait=60000
spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
spring.datasource.druid.minEvictableIdleTimeMillis=300000
spring.datasource.druid.validationQuery=SELECT 1
spring.datasource.druid.testWhileIdle=true
spring.datasource.druid.testOnBorrow=true
spring.datasource.druid.testOnReturn=false
spring.datasource.druid.poolPreparedStatements=true
spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.druid.filters=stat,wall
spring.datasource.druid.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1

#mybatis-plus
mybatis-plus.global-config.db-config.id-type=auto
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.auto-mapping-behavior=full
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.mapper-locations=classpath*:mapper/*Mapper.xml

#pageHelper
pagehelper.helper-dialect=mysql
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true
pagehelper.pageSizeZero=true
pagehelper.params=count=countSql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值