Flowable SpringBoot2.X集成
1. 添加pom依赖
主要依赖如下:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<flowable.version>6.4.0</flowable.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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-basic</artifactId>
<version>${flowable.version}</version>
</dependency>
<!-- 热部署 optional=true,依赖不会传递,该项目依赖devtools;之后依赖myboot项目的项目如果想要使用devtools,需要重新引入 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>true</scope>
</dependency>
</dependencies>
注意事项
在flowable与springboot2.x集成过程中,flowable相关表自动创建不能成功,发现是mysql驱动引起的。springboot2.x的mysql驱动是 mysql-connector-java 6(com.mysql.cj.jdbc.Driver),jar包依赖为6以上版本。将mysql驱动改为mysql-connector-java 5(com.mysql.jdbc.Driver),jar包依赖改为6以下版本,flowable相关表可以自动创建成功
2. application.yml文件配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/activiti_springboot?characterEncoding=UTF-8
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
#flowable:
# database-schema-update: create-drop
# check-process-definitions: false
3. 启动
启动引导类,启动成功后,观察mysql数据库,可以查看到自动生成的flowable相关数据表。