springboot2.1.6整合activiti6.0(一)
一、pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.badcat</groupId>
<artifactId>activiti_demo</artifactId>
<version>0.0.1-SNAPSHOT</version> <name>activiti_demo</name>
<description>springboot2.1.6整合activiti6.0</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.0.0</maven-jar-plugin.version>
<druid.version>1.1.14</druid.version>
<mysql.version>8.0.16</mysql.version>
<activiti.starter.version>6.0.0</activiti.starter.version>
</properties> <dependencies> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <!--阿里数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency> <!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency> <!-- activiti -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter-basic</artifactId>
<version>${activiti.starter.version}</version>
</dependency>
<!-- SpringBoot 测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </project>
二、application.yml
server:
port: 8087
tomcat:
uri-encoding: UTF-8
spring:
datasource:
url: jdbc:mysql://localhost/activiti6?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: root
password: 111111
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
# 下面为连接池的补充设置,应用到上面所有数据源中
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
max-active: 20
# 配置获取连接等待超时的时间
max-wait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
time-between-eviction-runs-millis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
# 打开PSCache,并且指定每个连接上PSCache的大小
pool-prepared-statements: true
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
max-pool-prepared-statement-per-connection-size: 20
filters: stat,wall
use-global-data-source-stat: true
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
activiti:
check-process-definitions: false
#flase: 默认值。activiti在启动时,会对比数据库表中保存的版本,如果没有表或者版本不匹配,将抛出异常。(生产环境常用)
#true: activiti会对数据库中所有表进行更新操作。如果表不存在,则自动创建。(开发时常用)
#create_drop: 在activiti启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)。(单元测试常用)
#rop-create: 在activiti启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎)。
database-schema-update: true
三、Aplication.java
注意:@SpringBootApplication 后添加 exclude = {SecurityAutoConfiguration.class }
package com.badcat; import org.activiti.spring.boot.SecurityAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; /**
* 启动程序
*/
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
public class Application
{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
四、运行Aplication.java,发现数据库多出了28张表

五、创建config类
import org.activiti.engine.*;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; /**
* @author badcat
* Date 2021/3/10
* Time 16:01
*/
@Configuration
public class ActivitiConfig {
@Autowired
private DataSource dataSource;
@Autowired
private PlatformTransactionManager platformTransactionManager; private SpringProcessEngineConfiguration springProcessEngineConfiguration(){
SpringProcessEngineConfiguration spec = new SpringProcessEngineConfiguration();
spec.setDataSource(dataSource);
spec.setTransactionManager(platformTransactionManager);
spec.setDatabaseSchemaUpdate("true");
return spec;
} private ProcessEngineFactoryBean processEngine(){
ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
processEngineFactoryBean.setProcessEngineConfiguration(springProcessEngineConfiguration());
return processEngineFactoryBean;
} @Bean
public RepositoryService repositoryService() throws Exception{
return processEngine().getObject().getRepositoryService();
}
@Bean
public RuntimeService runtimeService() throws Exception{
return processEngine().getObject().getRuntimeService();
}
@Bean
public TaskService taskService() throws Exception{
return processEngine().getObject().getTaskService();
}
@Bean
public HistoryService historyService() throws Exception{
return processEngine().getObject().getHistoryService();
}
@Bean
public FormService formService() throws Exception{
return processEngine().getObject().getFormService();
}
}
六、创建测试类
其中BPMN/process.bpmn是提前准备的流程定义文import org.activiti.engine.RepositoryServicimport org.activiti.engine.repository.Deployment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; /**
* @author badcat
* Date 2021/3/10
* Time 16:09
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class Deployment_test { @Autowired
private RepositoryService repositoryService; @Test
public void initDeploymentBPMN(){
String filename="BPMN/process.bpmn";
Deployment deployment=repositoryService.createDeployment()
.addClasspathResource(filename)
.deploy();
System.out.println(deployment.getId());
}
}
运行就可以看到数据库中的数据了。
springboot2.1.6整合activiti6.0(一)的更多相关文章
- Activiti工作流框架学习笔记(二)之springboot2.0整合工作流Activiti6.0
以前在工作当中做过不少与工作流Activiti有关的工作,当时都是spring集成activiti5.22的项目,现在回过头去看,其实版本已经稍微老了,因此,基于先前的工作经验,决定用较新版本的技术来 ...
- SpringBoot2整合activiti6环境搭建
SpringBoot2整合activiti6环境搭建 依赖 <dependencies> <dependency> <groupId>org.springframe ...
- springboot2.1.7整合mybati3.5.2与mysql8.0.13
springboot2.x已经发布一段时间,博主在这里使用springboot2.1.7整合mybatis3.5.2,使用的数据库为mysql8.0.13 1. 导入依赖 <!--mysql-- ...
- SpringBoot2.1.6 整合CXF 实现Webservice
SpringBoot2.1.6 整合CXF 实现Webservice 前言 最近LZ产品需要对接公司内部通讯工具,采用的是Webservice接口.产品框架用的SpringBoot2.1.6,于是采用 ...
- SpringBoot2.2.5整合ElasticSearch7.9.2
1:前言 为什么是SpringBoot2.2.5,不是其他的SpringBoot版本,原因有两个: 1:SpringBoot2.2.0以上才能支持ElasticSearch7.x版本. 2:Sprin ...
- Activiti6.0 安装出错 log4j:ERROR setFile(null,true) call failed.
由于要选择一款合适的流程引擎,需要在jbpm和Activiti之间做对比,我这边负责Activiti的测试. 看到Activiti官网(http://www.activiti.org/download ...
- Maven整合Spring3.0+Mybatis3.2+Struts2.3+查找坐标+jar包依赖(五)
依赖传递 只添加了一个struts2-core依赖,发现项目中出现了很多jar,这种情况 叫 依赖传递
- QQ登录整合/oauth2.0认证-04-调整到QQ互联进行QQ登录
---------------------------------目录------------------------------------- QQ登录整合/oauth2.0认证-03-对第二节的代 ...
- QQ登录整合/oauth2.0认证-03-对第二节的代码改进
---------------------------目录---------------------------------- QQ登录整合/oauth2.0认证-01-申请appkey和appid ...
- QQ登录整合/oauth2.0认证-02-跳转到QQ互联页
---------------------------目录---------------------------------- QQ登录整合/oauth2.0认证-01-申请appkey和appid ...
随机推荐
- Premiere剪辑加速
使用AE或者Premire的时候,如果需要导出文件,有的文件还是挺大的,处理起来疯狂占用CPU,经常导致别的工作无法进行. 如果能够使用GPU进行压缩工作就好了,如果你用一块独立显卡,那么就可以正常使 ...
- opencv+Linux源码编译安装及引用
(一)下载 opencv下载地址:https://opencv.org/releases/ opencv_contrib下载地址:https://github.com/opencv/opencv_co ...
- 该怎么解决no route to host
出现No route to host 的时候,有如下几种可能: 1.对方的域名确实不通 2.本机自己开了防火墙 3.本机的etc/hosts 里面没有配置本机的机器名和ip (可能性最大) 其中第三点 ...
- 【转载】 《SpringBoot2.0 实战》系列-集成Quartz定时任务(持久化到数据库)
https://blog.csdn.net/HXNLYW/article/details/95055601 一.增加依赖 我们使用的spring-boot-starter-quartz,所以不用显示指 ...
- Docker使用:利用宝塔面板Docker管理器快速搭建PHP、Java、Python、nodejs等配套运行环境
思路:阿里云购买服务器选择centos7宝塔系统做宿主机,登录宝塔安装Docker管理器,获取一个centos7镜像,创建容器在里面再安装个宝塔后部署PHP.Python等. 点击购买阿里云云服务器, ...
- 在 .NET 9 中使用 Scalar 替代 Swagger
前言 在.NET 9发布以后ASP.NET Core官方团队发布公告已经将Swashbuckle.AspNetCore(一个为ASP.NET Core API提供Swagger工具的项目)从ASP.N ...
- 后端开发之chrome开发者模式-copy
1. 场景描述 java开发前后端分离模式越来越流行,后端人员可以直接使用swagger进行接口调试(前后端分离之Swagger2),但是调试的时候,需要设置入参,假如该模块不是软件老王开发的,接别人 ...
- react中refs的使用
1.在dom元素中直接使用ref 意思就是可以在组件中创建一个dom节点的textInput,并将ref直接绑定到他 <script src="https://unpkg.com/@b ...
- 2025高级java面试精华及复习方向总结
1. Java基础 顶顶顶顶的点点滴滴 1.1 java集合关系结构图 1.2 如何保证ArrayList的线程安全 方法一: 使用 Collections 工具类中的 synchronizedLis ...
- C :文件
一直没有系统学习过该章节,现参考<C语言程序设计 (第四版)谭浩强> C文件基本知识 什么是文件 文件名 文件的分类 文件缓冲区 文件类型指针 typedef struct { short ...