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

边栏推荐
- 【mycat】mycat介绍
- Pycharm configures LAN access, and the LAN cannot access the solution
- Substrate 技术及生态5月大事记 | Square One 计划启动,波卡上线 XCM!
- Principle of fusdt liquidity pledge mining development logic system
- sunset: noontide靶机渗透-vulnhub
- Analysis of Dao liquidity dual currency pledge mining development principle
- MySQL 批量插入demo
- Development technical guide | the most complete technical documents, tutorials and courses of substrate and Polkadot
- Public chain Sui layer1 network
- Read "Enlightenment: a 20-year career experience of an IT executive"
猜你喜欢

Flink task, sub task, task slot and parallelism

Vulnhub funbox: rookie (funbox2) target penetration

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

How to forcibly uninstall Google browser? Don't worry about Google opening as a whiteboard. It's effective for personal testing.

MySQL之CRUD

达梦数据库_LENGTH_IN_CHAR和CHARSET的影响情况

jsp标签

达梦数据库_DISQL下各种连接数据库的方法和执行SQL、脚本的方法

MySQL之函数运用

Mapboxgl + GeoServer configuration local map tutorial
随机推荐
XML之建模
读《悟道:一位IT高管20年的职场心经》
mysql数据库的授权访问
Flink Task、Sub-Task、task slot和parallelism
Creation and generation of SVG format map in Heilongjiang Province
Why is music NFT popular? Polkadot may become the best choice for developing music NFT
【奖励发放】OneOS专区首届征文活动评奖结果公布
Gavin wood, founder of Poka: what will happen to Poka governance V2?
微信小程序报错request:fail -2:net::ERR_FAILED
GeoServer automatically uploads shapefiles
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.
Substrate 技术及生态6月大事记 | Polkadot Decoded 圆满落幕,黑客松获胜项目为生态注入新生力量
波卡生态发展不设限的奥义——多维解读平行链
Mobile software development ISO simple wechat
Flink重启策略
4. Draw a red triangle and a yellow square on the screen. Triangle in the back, small; Square in front, big. Using the fusion technology, the triangle can be seen through the square, and the source an
Web3 Foundation grant program empowers developers to review four successful projects
sunset: noontide靶机渗透-vulnhub
MySQL queries the last four digits of the mobile phone number. How to write the first few digits?
关于DAO流动性双币质押挖矿开发原理分析