Activiti创建表(三)
创建Mysql
创建 mysql 数据库 activiti(名字任意):
CREATE DATABASE activiti DEFAULT CHARACTER SET utf8;
pom.xml
- <properties>
- <slf4j.version>1.6.6</slf4j.version>
- <log4j.version>1.2.12</log4j.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-engine</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-spring</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-bpmn-model</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-bpmn-converter</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-json-converter</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-bpmn-layout</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <dependency>
- <groupId>org.activiti.cloud</groupId>
- <artifactId>activiti-cloud-services-api</artifactId>
- <version>7.0.0.Beta1</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>8.0.15</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>
- <!-- log end -->
- <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>
- </dependencies>
- <repositories>
- <repository>
- <id>alfresco</id>
- <name>Activiti Releases</name>
- <url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-releases/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
log4j.properties
- # 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:\axis.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
activiti.cfg.xml
- <?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?serverTimezone=UTC" />
- <property name="username" value="root" />
- <property name="password" value="123456" />
- </bean>
- <!--activiti单独运行的ProcessEngine配置对象(processEngineConfiguration),使用单独启动方式
- 默认情况下:bean的id=processEngineConfiguration
- -->
- <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
- <!--代表数据源-->
- <property name="dataSource" ref="dataSource"></property>
- <!-- <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" />-->
- <!--代表是否生成表结构-->
- <property name="databaseSchemaUpdate" value="true"/>
- </bean>
- </beans>
关于 processEngineConfiguration 中的 databaseSchemaUpdate 参数, 通过此参数设计 activiti
数据表的处理策略,参数如下:
false(默认):检查数据库表的版本和依赖库的版本, 如果版本不匹配就抛出异常。
true: 构建流程引擎时,执行检查,如果需要就执行更新。 如果表不存在,就创建。
create-drop: 构建流程引擎时创建数据库表, 关闭流程引擎时删除这些表。
drop-create:先删除表再创建表。
create: 构建流程引擎时创建数据库表, 关闭流程引擎时不删除这些表。
注意:在 activiti.cfg.xml 配置文件中的 dataSource 和 processEngineConfiguration 也可以使用一次
性配置出来。
- <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/itcast0711activiti"/>
- <property name="jdbcUsername" value="root"/>
- <property name="jdbcPassword" value="root"/>
- <property name="databaseSchemaUpdate" value="true"/>
- </bean>
测试类
- /**
- * 测试类
- * 作用:测试activiti所需要的25张表的生成
- */
- public class ActivitiTest {
- // @Test
- // public void testGenTable(){
- // //条件:1.activiti配置文件名称:activiti.cfg.xml 2.bean的id="processEngineConfiguration"
- // ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
- // System.out.println(processEngine);
- //
- // // HistoryService historyService = processEngine.getHistoryService();
- //
- // }
- @Test
- public void testGenTable(){
- //1.创建ProcessEngineConfiguration对象 第一个参数:配置文件名称 第二个参数是processEngineConfiguration的bean的id
- ProcessEngineConfiguration configuration = ProcessEngineConfiguration
- .createProcessEngineConfigurationFromResource("activiti.cfg.xml");
- //2.创建ProcesEngine对象
- ProcessEngine processEngine = configuration.buildProcessEngine();
- //3.输出processEngine对象
- System.out.println(processEngine);
- }
- }
说明:
1、运行以上程序段即可完成 activiti 数据库创建,通过改变 activiti.cfg.xml 中
databaseSchemaUpdate 参数的值执行不同的数据表处理策略。
2 、 上 边 的 方法 createProcessEngineConfigurationFromResource 在执行时在
activiti.cfg.xml 中找固定的名称 processEngineConfiguration
也可以使用重载方法调用,这时可以不用限定 processEngineConfiguration 名称
Activiti 的表都以 ACT_开头。 第二部分是表示表的用途的两个字母标识。 用途也和服务的 API 对
应。
ACT_RE_*: 'RE'表示 repository。 这个前缀的表包含了流程定义和流程静态资源 (图片,
规则,等等)。
ACT_RU_*: 'RU'表示 runtime。 这些运行时的表,包含流程实例,任务,变量,异步任务,
等运行中的数据。 Activiti 只在流程实例执行过程中保存这些数据, 在流程结束时就会删
除这些记录。 这样运行时表可以一直很小速度很快。
ACT_HI_*: 'HI'表示 history。 这些表包含历史数据,比如历史流程实例, 变量,任务等
等。
ACT_GE_*: GE 表示 general。 通用数据, 用于不同场景下。
Activiti创建表(三)的更多相关文章
- activiti自定义流程之整合(二):使用angular js整合ueditor创建表单
注:整体环境搭建:activiti自定义流程之整合(一):整体环境配置 基础环境搭建完毕,接下来就该正式着手代码编写了,在说代码之前,我觉得有必要先说明一下activit自定义流程的操作. 抛开自定义 ...
- activiti自定义流程之自定义表单(二):创建表单
注:环境配置:activiti自定义流程之自定义表单(一):环境配置 在上一节自定义表单环境搭建好以后,我就正式开始尝试自己创建表单,在后台的处理就比较常规,主要是针对ueditor插件的功能在前端进 ...
- PHP连接数据库、创建数据库、创建表的三种方式
这篇博客主要介绍了三种方式来连接MySQL数据库以及创建数据库.创建表.(代码是我在原来的基础上改的) MySQLi - 面向对象 MySQLi - 面向过程 PDO MySQLi 面向对象 < ...
- 第三百零六节,Django框架,models.py模块,数据库操作——创建表、数据类型、索引、admin后台,补充Django目录说明以及全局配置文件配置
Django框架,models.py模块,数据库操作——创建表.数据类型.索引.admin后台,补充Django目录说明以及全局配置文件配置 数据库配置 django默认支持sqlite,mysql, ...
- Activiti 配置Oracle不能自动创建表解决方法
使用配置文件创建工作流表 <bean id="processEngineConfiguration" class="org.activiti.engine.impl ...
- activiti自己定义流程之整合(二):使用angular js整合ueditor创建表单
基础环境搭建完成,接下来就该正式着手代码编写了,在说代码之前.我认为有必要先说明一下activit自己定义流程的操作. 抛开自己定义的表单不谈.通过之前的了解,我们知道一个新的流程開始.是在启动流程实 ...
- 2019年6月14日 Web框架之Django_07 进阶操作(MTV与MVC、多对多表三种创建方式、前后端传输数据编码格式contentType、ajax、自定义分页器)
摘要 MTV与MVC 多对多表三种创建方式 ajax ,前后端传输数据编码格式contentType 批量插入数据和自定义分页器 一.MVC与MTV MVC(Model View Controller ...
- activiti自己定义流程之自己定义表单(二):创建表单
注:环境配置:activiti自己定义流程之自己定义表单(一):环境配置 在上一节自己定义表单环境搭建好以后,我就正式開始尝试自己创建表单,在后台的处理就比較常规,主要是针对ueditor插件的功能在 ...
- Django之modles 多对多创建第三张表
一.第一种:纯自动创建第三张表 纯自动 class Book(models.Model): title = models.CharField(max_length=32) price = models ...
随机推荐
- [ScreenOS] How to change the certificate that is used for SSL (HTTPS) WebUI Management
SUMMARY: This article provides information on how to change the certificate that is used for SSL (HT ...
- Chapter03 第二节 const限定符的使用
3.2 const限定符 const的作用:替代#define作为有类型检查的常量来使用.他的值被初始化后就固定了,成为一个只读变量,不能更改.(推荐使用特殊的命名规范来区分常量和非常量). cons ...
- disabled_button 按钮按不下去
X老师今天上课讲了前端知识,然后给了大家一个不能按的按钮,小宁惊奇地发现这个按钮按不下去,到底怎么才能按下去 检查元素 删除 按钮就可以摁了 出现答案
- MySQL-快速入门(10)触发器
1.什么是触发器 触发器是与表有关的命名数据库对象.触发器由事件来触发某个操作. 触发器是特殊的存储过程,触发器不需要call语句来调用,也不需要手工启动,只需要确定一个预定义的事件发生的时候,就会被 ...
- 2016青岛区域赛.Coding Contest(费用流 + 概率计算转换为加法计算)
Coding Contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 【JZOJ 3910】Idiot 的间谍网络
题面: Description 作为一名高级特工,Idiot 苦心经营多年,终于在敌国建立起一张共有n 名特工的庞大间谍网络. 当然,出于保密性的要求,间谍网络中的每名特工最多只会有一名直接领导.现在 ...
- SSM框架中数据库无法连接的问题
首先是SSM框架中所有的配置都是没有问题的,而且项目在其他人的环境上也能正常访问数据库:那么最有可能的就是数据库版本的问题导致数据库连接不上,服务器给我的报错是: 15:37:25.902 [C3P0 ...
- Print out Android kernel log
adb shell "su -c 'cat /proc/kmsg'" | tee kernel.log adb shell cat /proc/last_kmsg > las ...
- 【C#】获取"我的电脑"的名字,如This PC、这台计算机
原文:[C#]获取"我的电脑"的名字,如This PC.这台计算机 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接: ...
- 7.css3表格、列表、边框的样式设置--list/border
1.css表格: ①Border-collapse是否把表格边框合并为单一的边框.Separate默认值,collapse合并. ②Border-spacing分割单元格边框的距离. ③Caption ...