当前位置:网站首页>【activiti】activiti环境配置
【activiti】activiti环境配置
2022-07-24 05:19:00 【你怎么不笑了】
Activiti环境配置
1.下载activiti
Activiti下载地址:http://activiti.org/download.html ,或者使用Maven的依赖如下:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-dependencies</artifactId>
<version>7.0.0.Beta1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
2.流程设计器
根据idea版本自行百度activiti bpmn visualizer,或者Camunda Modeler,这里提供一个:https://www.jianshu.com/p/5942c4ee513c
3.数据库支持
activiti运行需要有数据库的支持,支持的数据库有:h2, mysql, oracle, postgres, mssql, db2。
Activiti 在运行时需要数据库的支持,使用25张表,把流程定义节点内容读取到数据库表中,以供后续使用。
3.1创建数据库
创建mysql数据库activiti,名字随意:
CREATE DATABASE activiti DEFAULT CHARACTER SET utf8;
4.生成数据表
4.1创建工程
创建一个maven工程,名字随意,maven依赖:
<properties>
<slf4j.version>1.6.6</slf4j.version>
<log4j.version>1.2.12</log4j.version>
<activiti.version>7.0.0.Beta1</activiti.version>
</properties>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti.version}</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- bpmn 模型处理 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-model</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- bpmn 转换 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-converter</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- bpmn json数据转换 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-json-converter</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- bpmn 布局 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-layout</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- activiti 云支持 -->
<dependency>
<groupId>org.activiti.cloud</groupId>
<artifactId>activiti-cloud-services-api</artifactId>
<version>${activiti.version}</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<!-- 链接池 -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- log start -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
4.2添加log4j日志配置
# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategory=INFO, CONSOLE debug info warn error fatal
log4j.rootCategory=debug, CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r[%15.15t] %-5p %30.30c %x - %m\n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=D:\logs\act\activiti.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r[%15.15t] %-5p %30.30c %x - %m\n
4.3activiti配置文件
这里先用activiti提供的默认方式来创建数据库表
默认方式的要求是在 resources 下创建 activiti.cfg.xml 文件,路径及文件名不能修改,不然activiti读取不到
activiti.cfg.xml
配置processEngineConfiguration和数据库连接,配置方式有两种:
方式一:直接配置processEngineConfiguration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contex
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 默认id对应的值 为processEngineConfiguration -->
<!-- processEngine Activiti的流程引擎 -->
<bean id="processEngineConfiguration"
class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti"/>
<property name="jdbcUsername" value="root"/>
<property name="jdbcPassword" value="root"/>
<!-- activiti数据库表处理策略 -->
<property name="databaseSchemaUpdate" value="true"/>
</bean>
</beans>
方式二:单独配置数据源,然后在processEngineConfiguration 引用
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/contex http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 这里可以使用 链接池 dbcp-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/activiti" />
<property name="username" value="root" />
<property name="password" value="root" />
<property name="maxActive" value="3" />
<property name="maxIdle" value="1" />
</bean>
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- 引用数据源 上面已经设置好了-->
<property name="dataSource" ref="dataSource" />
<!-- activiti数据库表处理策略 -->
<property name="databaseSchemaUpdate" value="true"/>
</bean>
</beans>
5.编写程序生成表
创建一个测试类,调用activiti的工具类,生成acitivti需要的数据库表。
直接使用activiti提供的工具类ProcessEngines,会默认读取classpath下的activiti.cfg.xml文件,读取其中的数据库配置,创建 ProcessEngine,在创建ProcessEngine 时会自动创建表。
代码如下:
@Test
public void testCreateTable() {
//使用classpath下的activiti.cfg.xml中的配置创建processEngine
//默认方式,会自动去找resource下的activiti.cfg.xml文件
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
System.out.println(processEngine);
}
说明:
运行上面的代码后就可创建activiti服务表。查看idea控制台,会看到创建表结构语句,以及初始化表数据语句。
完成后,会创建25张数据表

边栏推荐
- 波卡生态发展不设限的奥义——多维解读平行链
- PHP 多行文字内容的重复检测功能并统计重复次数
- 公司女同事深夜11点让我去她住处修电脑,原来是C盘爆红,看我一招搞定女同事....的电脑
- Open Web3, once unpopular decentralized identity (did)
- 渗透测试知识---行业术语
- Why is music NFT popular? Polkadot may become the best choice for developing music NFT
- MySQL的分页你还在使劲的limit?
- Flink state使用
- Flink 并行度的理解(parallel)
- Draw a moving teapot on the screen. The teapot first moves slowly towards the screen, becoming smaller and smaller, becoming more and more blurred; Then it grows bigger and clearer, and keeps repeatin
猜你喜欢

【mycat】mycat安装

Vulnhub solidstate: 1 target penetration test

黑龙江省SVG格式地图的创建及生成

Creation and generation of SVG format map in Heilongjiang Province

Penetration testing knowledge - industry terminology

Fusdt流动性质押挖矿开发逻辑系统原理

Insanity:1 (insanity hosting) target penetration vulnhub

Sunset: noontide target penetration vulnhub

Polkadot | 一文解读颠覆传统社媒的Liberty计划如何在波卡落地

Canvas - fill
随机推荐
Restore UI design draft
在 Polkadot 中进行创建的三种方式 —— 平行链、平行线程、智能合约
Open Web3, once unpopular decentralized identity (did)
达梦数据库_逻辑备份
OpenGL simulates the process of a ball falling to the ground and bouncing up in real life. Draw a ball on the screen, and the ball will fall from top to bottom, hit the ground and bounce up again.
整站下载器推荐
MySQL误操作后如何快速恢复数据
3. Draw a five sided cone with a square bottom on the screen. The bottom of the cone is on the xoz plane and the top of the cone is on the Y axis. Use the following figure to map the texture of the fo
mysql查询手机号码后四位,前几位怎么写?
Imitate Baidu API of Baidu map page of a website
Vulnhub solidstate: 1 target penetration test
Flink 生产环境配置建议
vulnhub-SolidState: 1靶机渗透测试
MySQL 批量插入demo
@Async 没有异步执行
OpenGL draws a cone on the screen, which has four faces, each of which is a triangle. Add lighting and texture effects to the cone
CESS 测试网上线!首个提供多元应用场景的去中心化存储网络
读《悟道:一位IT高管20年的职场心经》
Logic development analysis of LP dual currency liquidity pledge mining system
达梦数据库_常用初始化参数