当前位置:网站首页>【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张数据表

边栏推荐
- 稀缺性之于Web3:如何成为去中心化世界的胜利者
- 网页播放rtsp视频流
- Flink Format系列(1)-JSON
- C document reading and writing plus linked list addition, deletion, modification and query
- 网页内嵌B站视频,隐藏相关控件
- Moonbeam Orbiters Program:为收集人参与 Moonbeam 和 Moonriver 提供新方式
- 盘点波卡生态潜力项目 | 跨链特性促进多赛道繁荣
- The profound meaning of unlimited ecological development in Poka -- Multidimensional Interpretation of parallel chain
- Insanity:1 (insanity hosting) target penetration vulnhub
- jsp标签
猜你喜欢

Function analysis of GeoServer rest API

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

达梦数据库_逻辑架构基础

jsp标签

Tree structure + node

haclabs: no_name(HL.ova)靶机渗透-Vulnhub

Oracle数据库的逻辑结构

Vulnhub funbox: rookie (funbox2) target penetration

Hurry in!! Easily master the three structures of "sequence", "branch" and "cycle" of C language

Fusdt流动性质押挖矿开发逻辑系统原理
随机推荐
Flink 时间流处理
OpenGL draws two points on the screen, a blue point on the right, using anti aliasing technology, and a red point on the left, without anti aliasing technology. Compare the difference between the two
The repetition detection function of PHP multi line text content and count the number of repetitions
Function Closure
Flink重启策略
音乐 NFT 为什么火了?Polkadot 或将成为发展音乐 NFT 的最佳选择
盘点波卡生态潜力项目 | 跨链特性促进多赛道繁荣
微信小程序报错request:fail -2:net::ERR_FAILED
Canvas Bezier Bezier curve
MySQL queries the last four digits of the mobile phone number. How to write the first few digits?
Why is music NFT popular? Polkadot may become the best choice for developing music NFT
Substrate technology and ecology June memorabilia | Polkadot decoded came to a successful conclusion, and the hacker song winning project injected new forces into the ecosystem
Draw a square on the screen and use ice BMP texture maps the square; Draw a yellow teapot after the square. Assuming that the square is transparent, draw the mixed effect of teapot and square; Adjust
Inventory Poka ecological potential project | cross chain characteristics to promote the prosperity of multi track
读《悟道:一位IT高管20年的职场心经》
通用分页01
[Baidu map API] the version of the map JS API you are using is too low and no longer maintained. In order to ensure the normal use of the basic functions of the map, please upgrade to the latest versi
MySQL的分页你还在使劲的limit?
MySQL的使用
Canvas - round