引入Activiti配置文件activiti.cfg.xml
前面我们用代码实现了生成25张activiti表,今天我们用Activiti提供的activiti.cfg.xml配置文件来简化实现前面的功能;
官方文档参考地址:http://activiti.org/userguide/index.html#configuration
我们先在src/test/resources下创建一个xml文件 名字是:activiti.cfg.xml
然后我们从官方文档贴下参考的xml代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" /> <property name="jdbcDriver" value="org.h2.Driver" /> <property name="jdbcUsername" value="sa" /> <property name="jdbcPassword" value="" /> <property name="databaseSchemaUpdate" value="true" /> <property name="jobExecutorActivate" value="false" /> <property name="asyncExecutorEnabled" value="true" /> <property name="asyncExecutorActivate" value="false" /> <property name="mailServerHost" value="mail.my-corp.com" /> <property name="mailServerPort" value="5025" /> </bean></beans> |
这里的话,我们要根据我们的项目 修改jdbcUrl jdbcDriver jdbcUsername jdbcPassword 当然还有下面的配置我们可以去掉一些 后面会降到这些配置的用途;
修改完后的xml如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/db_activiti" /> <property name="jdbcDriver" value="com.mysql.jdbc.Driver" /> <property name="jdbcUsername" value="root" /> <property name="jdbcPassword" value="123456" /> <property name="databaseSchemaUpdate" value="true" /> </bean></beans> |
接下来我们就是要通过代码来读取配置文件,然后获取工作流引擎实例:
代码如下:
|
1
2
3
4
5
6
7
8
9
10
|
/** * 使用xml配置 简化 */@Testpublic void testCreateTableWithXml(){ // 引擎配置 ProcessEngineConfiguration pec=ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml"); // 获取流程引擎对象 ProcessEngine processEngine=pec.buildProcessEngine();} |
然后我们测试的时候 先把前面db_activiti数据下的表 全部删除;
然后运行上面的测试类,我们会发现 表自动生成了:

表依然是前面的25张表;
我们会发现,使用xml配置会简化很多东西。。
完整代码打包下载:http://pan.baidu.com/s/1nuSJ3kd
引入Activiti配置文件activiti.cfg.xml的更多相关文章
- 1-2 hibernate主配置文件hibernate.cfg.xml详解
详 http://www.cnblogs.com/biehongli/p/6531575.html Hibernate的主配置文件hibernate.cfg.xml 1:Hibernate的主配置文件 ...
- Hibernate的配置文件,hibernate.cfg.xml
单纯的只针对持久层框架 Hibernate 配置文件的一些总结 一.Hibernate底层原理 1. Hibernate保存原理 目的:把domain对象保存到数据库的表,形成一条记录. sql: i ...
- Hibernate框架 主配置文件 Hibernate.cfg.xml 映射配置 说明
1 主配置文件 Hibernate.cfg.xml 主配置文件中主要配置:数据库连接信息.其他参数.映射信息! 常用配置查看源码: hibernate-distribution-3.6.0.Final ...
- hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
原文地址:http://blog.csdn.net/qiaqia609/article/details/9456489 hibernate.cfg.xml -标准的XML文件的起始行,version= ...
- hibernate配置文件hibernate.cfg.xml的详细解释
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> <?x ...
- hibernate篇章三-- hibernate配置文件hibernate.cfg.xml的详细解释
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> <?xml version='1.0' ...
- Hibernate 配置文件hibernate.cfg.xml的详细
<!--标准的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的编码方式--> <?xml ...
- 转: hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释
http://blog.csdn.net/yuhui123999/article/details/51886531 hibernate.cfg.xml -标准的XML文件的起始行,version='1 ...
- Hibernate(3)配置文件hibernate.cfg.xml
5.配置文件 Hibernate 配置文件主要用于配置数据库连接和 Hibernate 运行时所需的各种属性,每个 Hibernate 配置文件对应一个 Configuration 对象 Hibern ...
随机推荐
- C# async await 死锁问题总结
可能发生死锁的程序类型 1.WPF/WinForm程序 2.asp.net (不包括asp.net mvc)程序 死锁的产生原理 对异步方法返回的Task调用Wait()或访问Result属性时,可能 ...
- Linux学习之路--shell学习
shell基础知识 什么是Shell Shell是命令解释器(command interpreter),是Unix操作系统的用户接口,程序从用户接口得到输入信息,shell将用户程序及其输入翻译成操作 ...
- HDU5179 beautiful number 题解 数位DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5179 题目大意: 给你一个数 \(A = a_1a_2 \cdots a_n\) ,我们称 \(A\) ...
- JVM系列五(javac 编译器).
一.概述 我们都知道 *.java 文件要首先被编译成 *.class 文件才能被 JVM 认识,这部分的工作主要由 Javac 来完成,类似于 Javac 这样的我们称之为前端编译器: 但是 *.c ...
- C# 数独求解算法。
前言 数独是一种有趣的智力游戏,但是部分高难度数独在求解过程中经常出现大量单元格有多个候选数字可以填入,不得不尝试填写某个数字然后继续推导的方法.不幸的是这种方法经常出现填到一半才发现有单元格无数可填 ...
- schedule of 2016-09-12~2016-09-18(Monday~Sunday)——1st semester of 2nd Grade
2016/9/12 Monday 1.send present to Teacher Wei&hu 2.make ppt for 1st database 2.0 meeting for al ...
- 关于revit的外部扩展存储
最近被revit的外部扩展存储搞得死去活来,作为日后再次使用的预防针,此处随手留下印记,以作警示. 首先我们知道外部扩展存储ExtensibleStorage是revit提供给revit二次开发人员用 ...
- 各种小的 dp (精)
Q~ 抛一枚硬币 n 次,每次可能是正面或者反面向上,求没有连续超过 k 次硬币向上的方案数 A : dp[ i ] 表示到 i 位置的方案数, 1 . 当 i < k 时, dp[i] = d ...
- python IO非阻塞模型
server端 import socket sk = socket.socket() sk.bind(('127.0.0.1', 8010)) sk.setblocking(False) # sk.l ...
- Java入门 - 语言基础 - 04.对象和类
原文地址:http://www.work100.net/training/java-object-class.html 更多教程:光束云 - 免费课程 对象和类 序号 文内章节 视频 1 概述 2 J ...