jbpm springboot mysql_SpringBoot开发案例之整合Activiti工作流引擎
前言
JBPM是目前市場上主流開源工作引擎之一,在創建者Tom Baeyens離開JBoss后,JBPM的下一個版本jBPM5完全放棄了jBPM4的基礎代碼,基于Drools Flow重頭來過,目前官網已經推出了JBPM7的beta版本;Tom Baeyens加入Alfresco后很快推出了新的基于jBPM4的開源工作流系統Activiti。由此可以推測JBoss內部對jBPM未來版本的架構實現產生了嚴重的意見分歧。
環境軟件版本SpringBoot1.5.10
activiti-spring-boot-starter-basic6.0
搭建
花了半天的時間對比了下JBPM 和 Activit,以及兩個工作流的不同版本,最終選擇了 Activiti6 來實現,理由如下:JBPM 網上集成的資料甚少,且新版本相對比較笨重。
Activiti 相對豐富的資料,并且高度與 SpringBoot 集成,之所以選擇 Activiti6 版本,是由于目前只有版本6的集成 starter。
創建 pom.xml:
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.itstyle.bpm
spring-boot-activiti
jar
0.0.1-SNAPSHOT
spring-boot-activiti
http://maven.apache.org
UTF-8
org.springframework.boot
spring-boot-starter-parent
1.5.10.RELEASE
org.springframework.boot
spring-boot-starter-web
org.activiti
activiti-spring-boot-starter-basic
6.0.0
spring-boot-activiti
配置 application.properties:server.context-path=/
server.port=8080
server.session-timeout=60
server.tomcat.max-threads=100
server.tomcat.uri-encoding=UTF-8
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/spring-boot-activiti?characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" property. Default to "create-drop" when using an embedded database, "none" otherwise.
spring.jpa.hibernate.ddl-auto = update
# Hibernate 4 naming strategy fully qualified name. Not supported with Hibernate 5.
spring.jpa.hibernate.naming.strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
#每次應用啟動不檢查Activiti數據表是否存在及版本號是否匹配,提升應用啟動速度
spring.activiti.database-schema-update=false
#保存歷史數據級別設置為full最高級別,便于歷史數據的追溯
spring.activiti.history-level=full
聲名為配置類 ActivitiConfig:@Configuration//聲名為配置類,繼承Activiti抽象配置類
public class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource activitiDataSource() {
return DataSourceBuilder.create().build();
}
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
PlatformTransactionManager transactionManager,
SpringAsyncExecutor springAsyncExecutor) throws IOException {
return baseSpringProcessEngineConfiguration(
activitiDataSource(),
transactionManager,
springAsyncExecutor);
}
}
啟動項目,會自動生成28張表:act_ge_ 通用數據表,ge是general的縮寫
act_hi_ 歷史數據表,hi是history的縮寫,對應HistoryService接口
act_id_ 身份數據表,id是identity的縮寫,對應IdentityService接口
act_re_ 流程存儲表,re是repository的縮寫,對應RepositoryService接口,存儲流程部署和流程定義等靜態數據
act_ru_ 運行時數據表,ru是runtime的縮寫,對應RuntimeService接口和TaskService接口,存儲流程實例和用戶任務等動態數據
演示
一個簡單的請假流程演示:
說明
其實開源社區有不少工作流的案例,但都不是自己想要的類型。由于工作需要,會逐步分享開發中所遇到的疑難問題和小細節,后面會開源一個簡單的工作流完整實例,敬請關注。
總結
以上是生活随笔為你收集整理的jbpm springboot mysql_SpringBoot开发案例之整合Activiti工作流引擎的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java获取oracle表空间_Orac
- 下一篇: mysql group by over,