SpringBoot2.x+mybatis plus3.x integrated Activit7 version

Text/Zhu Jiqian

In the Activiti6 version, if you want to integrate it into Springboot, you need to write some additional configuration classes. I once summarized the relevant configuration process in the article Springboot2.0 Integrated Workflow Activiti6.0 in Activiti Workflow Framework Study Notes (2) . Interested students can click on the link to take a look.

After switching to the Activiti7 version, there is no need to write another configuration class to inject the workflow Activiti interfaces into the IOC. It can already automatically inject the corresponding service interfaces and only needs to rely on the corresponding jar package and the yaml configuration file. Configure the corresponding parameters here to achieve the integration of SpringBoot+Activiti7.

This is accomplished in two steps.

1. Maven depends on Activiti7 version

 <properties>
        <activiti.version>7.1.0.M6</activiti.version>
 </properties>


<dependencies>
<dependency>
    <groupId>org.activiti.dependencies</groupId>
    <artifactId>activiti-dependencies</artifactId>
    <version>${activiti.version}</version>
    <type>pom</type>
</dependency>
<!--使用mybatis plus需排除掉mybatis-->
<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring-boot-starter</artifactId>
    <version>${activiti.version}</version>
    <exclusions>
        <exclusion>
            <groupId>de.odysseus.juel</groupId>
            <artifactId>juel-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>de.odysseus.juel</groupId>
            <artifactId>juel-spi</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
        </exclusion>
    </exclusions>
</dependency>
</dependencies>

One thing to note is that because mybatis plus is used as the ORM framework, you need to exclude the mybatis dependency, otherwise an exception message will occur when the project is started.

2. Configure the corresponding startup parameters in the yaml file

spring:
  datasource:
    name: druidDataSoure
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      driver-class-name: com.mysql.jdbc.Driver
      url: jdbc:mysql://127.0.0.1:3306/ftedb?useUnicode=true&characterEncoding=UTF-8&ueSSL=false&serverTimezone=GMT%2B8
      username: root
      password: root
  activiti:
    #1.false:默认值,activiti启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常
    #2.true:启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表
    #3.create_drop:启动时自动创建表,关闭时自动删除表
    #4.drop_create:启动时,删除旧表,再创建新表
    database-schema-update: true
    #activiti7默认不生成历史信息表,需手动设置开启
    db-history-used: true
    check-process-definitions: true
    #full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数
    history-level: full

After completing the above two steps, you can integrate Activit7 into the SpringBoot+mybatis plus project.

When you start the project, you will find that the corresponding workflow table structure is automatically generated in the database.

image

Guess you like

Origin blog.csdn.net/weixin_40706420/article/details/135182792