參考文檔:https://tkjohn.github.io/flowable-userguide/#springSpringBoot
課件代碼:https://gitee.com/flymini/codes01/tree/master/flowable_/learn-flowable04
****
<br/>
建議:MySQL5.7+,如果MySQL低于5.7可能會報異常。
<br/>
整合步驟如下:
**1. 創建一個SpringBoot項目,`pom.xml`如下**
```xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
```
**2. `resources/application.yml`**
```yml
spring:
datasource:
url: jdbc:mysql://localhost:3307/flowable_springboot?characterEncoding=utf8&useSSL=false&serverTimezone=UTC
username: root
password: uhg</flEt3dff
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
liquibase:
enabled: false #不需要每次啟動都檢查數據庫版本信息
flowable:
database-schema-update: true #數據庫更新策略,true-表存在則使用,不存在則自動創建
db-history-used: true #true-表示記錄歷史信息
history-level: full #記錄的歷史級別,full-最高級別,所有數據都記錄為歷史
async-executor-activate: false #關閉異步任務
check-process-definitions: false #false-不開啟自動部署
#如果開啟自動部署,當流程在目錄`resources/processes/*.bpmn`時會自動將流程部署到數據庫
```
更多配置參考:https://tkjohn.github.io/flowable-userguide/#springBootFlowableProperties
**3. 配置引擎**
```java
@Configuration
public class FlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
/**
* 防止生成的流程圖片中文亂碼
*/
@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
engineConfiguration.setActivityFontName("宋體");
engineConfiguration.setLabelFontName("宋體");
engineConfiguration.setAnnotationFontName("宋體");
}
}
```
**4. 運行啟動類**
當運行啟動類時,Flowable 會自動在數據庫中建表。
```java
@SpringBootApplication
public class FlowableBootApplication {
public static void main(String[] args) {
SpringApplication.run(FlowableBootApplication.class, args);
}
}
```
**5. 獲取各種服務接口了**
```java
@SpringBootTest
class FlowableBootApplicationTests {
@Autowired
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Autowired
private ManagementService managementService;
@Test
void contextLoads() {
//成功拿到服務接口org.flowable.engine.impl.RepositoryServiceImpl@1f229c40
System.out.println(repositoryService);
}
}
```
- Activiti流程引擎
- 工作流介紹
- Activiti是什么
- Activiti流程處理步驟
- Activiti環境搭建
- 搭建步驟
- 表結構介紹
- ActivitiAPI結構
- 認識流程符號
- 流程設計器的使用
- 流程處理步驟
- 亂碼問題
- 流程實例
- 流程實例是什么
- 業務標識
- 查詢流程實例
- 掛起/激活流程實例
- 個人任務
- 分配任務負責人
- 查詢待辦任務
- 辦理權限
- 流程變量
- 流程變量類型
- 流程變量作用域
- 使用流程變量控制流程
- 組任務
- 設置任務候選人
- 組任務辦理流程
- 網關
- 4種網關類型
- 排他網關
- 并行網關
- 包含網關
- 事件網關
- Spring整合Activiti
- SpringBoot整合Activiti
- Flowable流程引擎
- Flowable是什么
- Flowable與Activiti
- Flowable環境搭建
- FlowableAPI
- 流程引擎API與服務
- 流程處理步驟
- 流程部署
- 流程部署方式
- 流程定義版本
- 刪除已部署的流程
- 下載資源
- 流程實例
- 什么是流程實例
- 業務標識
- 查詢流程實例
- 掛起/激活流程實例
- 分配任務負責人
- 固定分配
- UEL表達式分配
- 監聽器分配
- 辦理權限
- 流程變量
- 流程變量類型
- 流程變量作用域
- 流程變量控制流程
- 組任務
- 設置任務候選人
- 組任務辦理流程
- 網關
- 排他網關
- 并行網關
- 包含網關
- 事件網關
- 歷史查詢
- 查詢歷史
- Spring整合Flowable
- 配置文件整合
- 配置類整合
- SpringBoot整合Flowable