Activiti工作流框架学习笔记(二)之springboot2.0整合工作流Activiti6.0

news/2024/5/18 22:01:22 标签: 学习, 笔记, 流程图

文/朱季谦

以前在工作当中做过不少与工作流Activiti有关的工作,当时都是spring集成activiti5.22的项目,现在回过头去看,其实版本已经稍微老了,因此,基于先前的工作经验,决定用较新版本的技术来重新梳理下以前接触过的技术。

决定用springboot2.0+Activiti6.0来做实践总结。

第一步,在springboot项目pom.xml文件引入相关依赖:

 1 <!--Activiti 工作流-->
 2 <dependency>
 3     <groupId>mysql</groupId>
 4     <artifactId>mysql-connector-java</artifactId>
 5     <scope>5.1.35</scope>
 6 </dependency>
 7 
 8 <dependency>
 9     <groupId>org.activiti</groupId>
10     <artifactId>activiti-spring</artifactId>
11     <version>6.0.0</version>
12 </dependency>
13 
14 <dependency>
15     <groupId>com.fasterxml.jackson.core</groupId>
16     <artifactId>jackson-core</artifactId>
17     <version>2.9.5</version>
18 </dependency>

第二步,建立Activiti的配置类

 1 @Configuration
 2 public class Activiticonfig {
 3 
 4     /**
 5      * 流程实例类,启动流程时创建
 6      * @return
 7      */
 8     @Bean
 9     public ProcessEngine processEngine(){
10           ProcessEngineConfiguration pro=ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
11           pro.setJdbcDriver("com.mysql.jdbc.Driver");
12           pro.setJdbcUrl("jdbc:mysql://localhost:3306/example?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=UTC&nullCatalogMeansCurrent=true");
13           pro.setJdbcUsername("root");
14           pro.setJdbcPassword("root");
15           //避免发布的图片和xml中文出现乱码
16           pro.setActivityFontName("宋体");
17           pro.setLabelFontName("宋体");
18           pro.setAnnotationFontName("宋体");
19           pro.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
20           return pro.buildProcessEngine();
21     }
22 
23 
24     /**
25      * 仓库服务类,用于管理bpmn文件与流程图片
26      * @return
27      */
28     @Bean
29     public RepositoryService repositoryService(){
30         return processEngine().getRepositoryService();
31     }
32 
33     /**
34      * 流程运行服务类,用于获取流程执行相关信息
35      * @return
36      */
37     @Bean
38     public RuntimeService runtimeService(){
39         return processEngine().getRuntimeService();
40     }
41 
42     /**
43      * 任务服务类,用户获取任务信息
44      * @return
45      */
46     @Bean
47     public TaskService taskService(){
48         return processEngine().getTaskService();
49     }
50 
51 
52     /**
53      * 获取正在运行或已经完成的流程实例历史信息
54      * @return
55      */
56     @Bean
57     public HistoryService historyService(){
58         return processEngine().getHistoryService();
59     }
60 
61     /**
62      * 流程引擎的管理与维护
63      * @return
64      */
65     @Bean
66     public ManagementService managementService(){
67         return processEngine().getManagementService();
68     }
69 
70     /**
71      * 创建、更新、删除,查询群组和用户
72      * @return
73      */
74     @Bean
75     public IdentityService identityService(){
76         return processEngine().getIdentityService();
77     }
78 
79 }

在springboot工程里简单加完这些配置后,启动项目,原以为可以正常生成Activi6.0工作流自带的28张表,但这时出现了一堆错误:

### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'example.act_ge_property' doesn't exist
### The error may exist in org/activiti/db/mapping/entity/Property.xml
### The error may involve org.activiti.engine.impl.persistence.entity.PropertyEntityImpl.selectProperty-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_GE_PROPERTY where NAME_ = ?
### Cause: java.sql.SQLSyntaxErrorException: Table 'example.act_ge_property' doesn't exist
出现这种问题主要是因为MySql的版本问题,在连接mysql的url后边加一个&nullCatalogMeansCurrent=true即可解决。
再次运行后,成功创建了28张Activiti自带的数据表——

接下来,将基于该搭建,对Activiti工作流引擎做更多操作实践。


http://www.niftyadmin.cn/n/5292066.html

相关文章

跨模态检索论文阅读:Plug-and-Play Regulators for Image-Text Matching用于图像文本匹配的即插即用调节器

Plug-and-Play Regulators for Image-Text Matching用于图像文本匹配的即插即用调节器 利用细粒度的对应关系和视觉语义比对在图像-文本匹配中显示出巨大的潜力。通常&#xff0c;最近的方法首先使用跨模态注意力单元来捕捉潜在的区域-单词交互&#xff0c;然后整合所有比对以获…

[react]react-router-dom 与 redux 版本升级

[react]react-router-dom 与 redux 版本升级 环境脚手架的升级react-router-dom 升级关于路由相关文件的写法--react-router-dom 5.0.1入口渲染文件App.js路由框架src/views/root/index.js路由守卫 src/views/routerguide/index.jsx路由文件src/views/page.js 关于路由相关文件…

数据库开发之子查询案例的详细解析

1.5 案例 基于之前设计的多表案例的表结构&#xff0c;我们来完成今天的多表查询案例需求。 准备环境 将资料中准备好的多表查询的数据准备的SQL脚本导入数据库中。 分类表&#xff1a;category 菜品表&#xff1a;dish 套餐表&#xff1a;setmeal 套餐菜品关系表&#x…

限制哪些IP能连接postgre

打开C:\Program Files\PostgreSQL\9.4\data\pg_hba.conf 以下代表本机能连&#xff0c;172.16.73.xx都能连&#xff08;/24就代表最后一位是0-255&#xff09;&#xff0c;如果是172.16.73.11/32那就是限制了172.16.73.11才能连&#xff08;实际我设置/32是无效的&#xff09;&…

语言模型:从n-gram到神经网络的演进

目录 1 前言2 语言模型的两个任务2.1 自然语言理解2.2 自然语言生成 3 n-gram模型4 神经网络语言模型5 结语 1 前言 语言模型是自然语言处理领域中的关键技术之一&#xff0c;它致力于理解和生成人类语言。从最初的n-gram模型到如今基于神经网络的深度学习模型&#xff0c;语言…

ASM GaN: 行业硅基氮化镓射频和功率设备标准模型—第一部分:直流、CV和射频模型

来源&#xff1a;ASM GaN: Industry Standard Model for GaN RF and Power Devices—Part 1: DC, CV, and RF Model (IEEE TRANSACTIONS ON ELECTRON DEVICES) 19年 摘要 本文介绍了GaN&#xff08;氮化镓&#xff09;HEMT&#xff08;高电子迁移率晶体管&#xff09;的先进S…

【Redis前奏曲】初识Redis

文章目录 一.Redis的一些特性(优点)1. 在内存中存储数据2. 可编程的3. 可扩展的4.持久化5. 聚集(集群)6. 高可用Redis快的原因 二. 使用案例1.数据库2. 缓存3. 消息队列 一.Redis的一些特性(优点) 我们在上一篇博客中说到,Redis是一个在内存中存储数据的中间件.用作数据库,数据…

Java系列-HTTP和HTTPS 的实现原理

HTTP&#xff08;Hypertext Transfer Protocol&#xff09;和HTTPS&#xff08;Hypertext Transfer Protocol Secure&#xff09;是用于在网络上传输数据的两种协议&#xff0c;它们在实现原理和安全性上有一些关键的区别。 HTTP 的实现原理&#xff1a; 1. 无连接性&#xf…