SpringBoot2集成Activiti6
Activiti是领先的轻量级的,以Java为中心的开源BPMN(Business Process Modeling Notation)引擎,实现了真正的流程自动化。下面介绍如何在SpringBoot环境下使用Maven集成Activiti6,来实现流程开发。
添加依赖
-
<dependency>
-
<groupId>org.activiti</groupId>
-
<artifactId>activiti-spring-boot-starter-basic</artifactId>
-
<version>6.0.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-jdbc</artifactId>
-
</dependency>
添加Processes目录
SpringBoot集成activiti默认会从classpath下的processes目录下读取流程定义文件,所以需要在src/main/resources目录下添加processes目录,并在目录中创建流程文件,添加目录后,目录结构变为:
如果没有processes目录,则需要修改配置spring.activiti.process-definition-location-prefix,指定流程文件存放目录。
Spring集成Activiti6默认支持**.bpmn20.xml和**.bpmn格式的流程定义文件,修改支持的文件格式,通过配置spring.activiti.process-definition-location-suffixes修改
如:
-
spring:
-
activiti:
-
check-process-definitions: true #自动检查、部署流程定义文件
-
database-schema-update: true #自动更新数据库结构
-
process-definition-location-prefix: classpath:/processes/ #流程定义文件存放目录
-
#process-definition-location-suffixes: #流程文件格式
-
# - **.bpmn20.xml
-
# - **.bpmn
启动项目时,如果没有流程部署,就不能通过自动注入,使用RuntimeService等API,依赖注入时后报错。
ActivitiProperties中定义了activiti的自动配置项,其他配置请查看ActivitiProperties属性。
添加数据源
添加数据源,项目中添加数据源,初始化数据库结构,后续保存流程数据,
-
spring :
-
#data source config
-
datasource :
-
driver : com.mysql.jdbc.Driver
-
url: jdbc:mysql://192.168.105.10:3306/test_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true
-
username : root
-
password : mysql
-
initsize : 10
-
maxActive : 20
-
minIdle : 10
-
maxWait : 120000
-
poolPreparedStatements : false
-
maxOpenPreparedStatements : -1
-
validationQuery : select 1
-
testOnborrow : true
-
testOnReturn : true
-
testWhileIdle : true
-
timeBetweenEvictionRunsMillis : 120000
-
filters : log4j,stat
添加流程
在项目中添加流程,创建文件simple.bpmn,添加内容
-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="Examples" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1539757531057" name="" targetNamespace="Examples" typeLanguage="http://www.w3.org/2001/XMLSchema">
-
<process id="oneTaskProcess" isClosed="false" name="The One Task Process" processType="None">
-
<startEvent id="theStart"/>
-
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask"/>
-
<userTask activiti:assignee="${user}" activiti:exclusive="true" id="theTask" name="my task"/>
-
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd"/>
-
<endEvent id="theEnd"/>
-
</process>
-
</definitions>
启动测试
编写SpringBoot启动类,启动项目,启动项目。
-
@SpringBootApplication(scanBasePackages = "com.legao.server")
-
@EnableSwagger2
-
public class WorkflowServer {
-
-
public static void main(String[] args) {
-
-
SpringApplication.run(WorkflowServer.class, args);
-
}
-
}
启动时,发现启动报错,
-
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
-
-
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
查看activiti-spring-boot-starter-basic-6.0.0.jar发现,org.activiti.spring.boot.SecurityAutoConfiguration编译报错,这时候将SecurityAutoConfiguration排除到SpringBoot启动之外,即@SpringBootApplication注解添加exclude = SecurityAutoConfiguration.class属性
-
@SpringBootApplication(scanBasePackages = "com.legao.server", exclude = SecurityAutoConfiguration.class)
-
@EnableSwagger2
-
public class WorkflowServer {
-
-
public static void main(String[] args) {
-
-
SpringApplication.run(WorkflowServer.class, args);
-
}
-
}
再启动发现启动正常,这时候SpringBoot集成activiti已经启动成功,查看数据库,Activiti6运行所需的28张表也已经创建成功。
-
ACT_EVT_LOG
-
ACT_GE_BYTEARRAY
-
ACT_GE_PROPERTY
-
ACT_HI_ACTINST
-
ACT_HI_ATTACHMENT
-
ACT_HI_COMMENT
-
ACT_HI_DETAIL
-
ACT_HI_IDENTITYLINK
-
ACT_HI_PROCINST
-
ACT_HI_TASKINST
-
ACT_HI_VARINST
-
ACT_ID_GROUP
-
ACT_ID_INFO
-
ACT_ID_MEMBERSHIP
-
ACT_ID_USER
-
ACT_PROCDEF_INFO
-
ACT_RE_DEPLOYMENT
-
ACT_RE_MODEL
-
ACT_RE_PROCDEF
-
ACT_RU_DEADLETTER_JOB
-
ACT_RU_EVENT_SUBSCR
-
ACT_RU_EXECUTION
-
ACT_RU_IDENTITYLINK
-
ACT_RU_JOB
-
ACT_RU_SUSPENDED_JOB
-
ACT_RU_TASK
-
ACT_RU_TIMER_JOB
-
ACT_RU_VARIABLE
(完)
原文地址:https://blog.csdn.net/weihao_/article/details/83241662
SpringBoot2集成Activiti6的更多相关文章
- SpringBoot2整合activiti6环境搭建
SpringBoot2整合activiti6环境搭建 依赖 <dependencies> <dependency> <groupId>org.springframe ...
- Activiti(二) springBoot2集成activiti,集成activiti在线设计器
摘要 本篇随笔主要记录springBoot2集成activiti流程引擎,并且嵌入activiti的在线设计器,可以通过浏览器直接编辑出我们需要的流程,不需要通过eclipse或者IDEA的actiB ...
- springboot集成activiti6.0多数据源的配置
最近公司开始开发springboot的项目,需要对工作流进行集成.目前activiti已经发布了7.0的版本,但是考虑到6.0版本还是比较新而且稳定的,决定还是选择activiti6.0的版本进行集成 ...
- springboot2集成pagehelper
springboot2集成pagehelper超级简单,本示例直接抄袭官方示例,仅将数据库由H2改成MySQL而已. 1. pom.xml <?xml version="1.0&quo ...
- UidGenerator springboot2集成篇
uid-generator 官网集成文档: https://github.com/baidu/uid-generator/blob/master/README.zh_cn.md 由于并没有提供spri ...
- SpringBoot2 集成三种连接池 c3p0 hikari druid
Hikari 1.首先集成 hikari springboot默认集成,只需要简单的配置即可 1.1 首先导入包 <dependency> <groupId>com.zaxxe ...
- SpringBoot2 集成日志,复杂业务下的自定义实现
本文源码:GitHub·点这里 || GitEE·点这里 一.日志体系集成 1.日志管理 在系统的开发中,最关键的一个组件工具就是日志,日志打印方便问题排查,或者生产事故回溯,日志记录用来监控并分析系 ...
- SSM集成activiti6.0错误集锦(一)
项目环境 Maven构建 数据库:Orcle12c 服务器:Tomcat9 <java.version>1.8</java.version> <activiti.vers ...
- springboot2集成activiti出错
报一个反射错误 java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy 解决方案:http ...
随机推荐
- vue-eslint配置文件
做项目的时候,我把eslint设置为了false,可想而知提交会产生的冲突 让我一个一个解决肯定不可能的,eslint的rule很多 在vue的配置文件.eslintrc.js中配置以下选项 这样只需 ...
- WordPress资料收集,以后整理
WordPress主题开发:实现分页功能 http://www.cnblogs.com/tinyphp/p/6361901.html WordPress如何调取显示指定文章 https://www.d ...
- 【weex】h5weex-example
这个就是一个练手的基础性的demo,不过也是有很多值得学习的东西的 效果如下 项目地址为:https://github.com/h5weex/h5weex-example 可能是我找到的项目比较少,很 ...
- PHP--反射的方法
反射,直观理解就是根据到达地找到出发地和来源.比如,一个光秃秃的对象,我们可以仅仅通过这个对象就能知道它所属的类.拥有哪些方法. 反射是指�php运行状态中,扩展分析PHP程序,导出或提出关于类.方法 ...
- echarts 重新渲染(重新绘制,重新加载数据)等
- python ndarray相关操作:转置、翻转
- Leetcode876.Middle of the Linked List链表的中间节点
给定一个带有头结点 head 的非空单链表,返回链表的中间结点. 如果有两个中间结点,则返回第二个中间结点. 示例 1: 输入:[1,2,3,4,5] 输出:此列表中的结点 3 (序列化形式:[3,4 ...
- startActivity 流程图
- C++中字符串的长度
定义一个字符串,求其长度: string str; str.length(); str.size();
- iOS 9开发小技巧
http://www.cocoachina.com/ios/20151217/14733.html 前言 "小黄鸭"法不仅适用于debug,也适用于学习新知识.表达是最好的吸收.本 ...