1.通过ProcessEngineConfiguration获取

 package cn.lonecloud.mavenActivi;

 import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
/**
* 通过使用ProcessEngineConfiguration获取
* @Title: ConfigByClass.java
* @Package cn.lonecloud.mavenActivi
* @Description:
* @author lonecloud
* @date 2016年8月22日 下午10:50:33
*/
public class ConfigByClass {
@Test
public void config() {
//获取config对象
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration();
//Jdbc设置
String jdbcDriver = "com.mysql.jdbc.Driver";
processEngineConfiguration.setJdbcDriver(jdbcDriver);
String jdbcUrl = "jdbc:mysql://localhost:3306/mavenActiviti?useUnicode=true&characterEncoding=utf-8";
processEngineConfiguration.setJdbcUrl(jdbcUrl);
String jdbcUsername = "root";
processEngineConfiguration.setJdbcUsername(jdbcUsername);
String jdbcPassword = "123456";
processEngineConfiguration.setJdbcPassword(jdbcPassword);
/**
* Checks the version of the DB schema against the library when the
* process engine is being created and throws an exception if the
* versions don't match.
*/
// public static final String DB_SCHEMA_UPDATE_FALSE = "false";//不自动创建新表 /**
* Creates the schema when the process engine is being created and drops
* the schema when the process engine is being closed.
*/
// public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";//每次运行创建新表 /**
* Upon building of the process engine, a check is performed and an
* update of the schema is performed if it is necessary.
*/
// public static final String DB_SCHEMA_UPDATE_TRUE = "true";设置自动对表结构进行改进和升级
//设置是否自动更新
processEngineConfiguration
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
//获取引擎对象
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
processEngine.close();
}
}

2.通过ProcessEngineConfiguration载入xml文件

xml文件:

 <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!--这里的类太多别导错了 -->
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- 配置流程引擎配置对象 -->
<property name="jdbcDriver" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?useUnicode=true&amp;characterEncoding=utf-8"></property>
<property name="jdbcUsername" value="root"></property>
<property name="jdbcPassword" value="123456"></property>
<!-- 注入数据源信息 -->
<property name="databaseSchemaUpdate" value="true"></property>
</bean> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
<!-- 注入自动建表设置 -->
<property name="processEngineConfiguration" ref="processEngineConfiguration"></property>
</bean>
</beans>

java

 package cn.lonecloud.mavenActivi;

 import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.junit.Test;
/**
* 通过通过配置文件进行初始化获取引擎对
* @Title: ConfigByConfig.java
* @Package cn.lonecloud.mavenActivi
* @Description:
* @author lonecloud
* @date 2016年8月22日 下午10:40:35
*/
public class ConfigByConfig {
/**
* 通过配置文件进行初始化获取引擎对象
* @Description:
*/
@Test
public void configByConf(){
//载入资源
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
//创建引擎
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
processEngine.getRepositoryService();
}
}

3.通过默认载入activiti.cfg.xml进行获取

      * 通过默认载入activiti.cfg.xml进行获取
* @Description:推荐使用
*/
@Test
public void configByDefault(){
//通过获取载入默认获取
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
processEngine.close();
}

这里的xml文件名必须设置为activiti.cfg.xml

Activiti获取ProcessEngine的三种方法的更多相关文章

  1. 体温数据上传程序开发+获取时间的三种方法+DB Browser下载及安装

    今天开始了体温上传程序的开发 今日所学: 获取时间 (21条消息) (转)安卓获取时间的三种方法_sharpeha的博客-CSDN博客_安卓获取时间 DB Browser安装教程 (20条消息) sq ...

  2. java 获取随机数的三种方法

    方法1(数据类型)(最小值+Math.random()*(最大值-最小值+1))例:(int)(1+Math.random()*(10-1+1))从1到10的int型随数 方法2获得随机数for (i ...

  3. URL转Drawable之 Android中获取网络图片的三种方法

    转载自: http://doinone.iteye.com/blog/1074283 Android中获取网络图片是一件耗时的操作,如果直接获取有可能会出现应用程序无响应(ANR:Applicatio ...

  4. android系统通过图片绝对路径获取URI的三种方法

    最近做项目要通过图片的绝对路径找到图片的URI,然后删除图片,小小总结一下获取URI的方法,亲自试验在 android 4.1.3的系统上都是可用的. 1.将所有的图片路径取出,遍历比较找到需要的路径 ...

  5. js jquery 获取服务器控件的三种方法

    由于ASP.NET网页运行后,服务器控件会随机生成客户端id,jquery获取时候不太好操作,google了下,总结有以下3种方法: 服务器控件代码:<asp:TextBox ID=" ...

  6. 获取IP的三种方法

    第一种 取本主机ip地址 public string GetLocalIp() { ///获取本地的IP地址 string AddressIP = string.Empty; foreach (IPA ...

  7. node获取当前路径的三种方法

    node提供了3种获取路径的方法  ,在当前目录下,运行node const {resolve} = require('path') console.log('__dirname : ' + __di ...

  8. java获取文件名的三种方法

    import java.io.File; import java.util.Arrays; public class FileName { /** * @param args */ public st ...

  9. js获取时间戳的三种方法

    1.Date.Now() 2.new Date().getTime() 3.Date.parse(new Date()) 其中1和2是相同含义 chrome控制台键入:Date.now() ===ne ...

随机推荐

  1. DataTable转泛型List

    在.net项目研发过程中,有时候需要将从数据库中获取的DataTable数据类型,转换为泛型集合,然后运用LINQ对集合进行操作,我将此总结一下,方便你我他. 核心类: public class Da ...

  2. Javascript学习--时间

    digit = [ [ [0,0,1,1,1,0,0], [0,1,1,0,1,1,0], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1,1,0,0,0,1,1], [1, ...

  3. 微信跳一跳的mini辅助设计

    前一段考试没时间写东西,就迟到补发一波,继电器触发触屏,arduino处理数据就行了,B站很多人做,我也来一个,个人测试数据增益为2.1左右,即  延时=距离X2.1x10 void setup() ...

  4. linux_磁盘分区

    分区并没有数据内容只是改变分区表,保存在0磁头,0磁道1扇区除MBR引导后64bytes中,只能有4个组分区,4个以上要一个扩展分区 引导MBR,保存在446字节中 磁盘想要存放数据,首先要分区,可以 ...

  5. scrapy_创建_调试

    如何创建scrapy项目? 输入命令: scrapy startproject project_name 在当前目录下创建名字叫project_name的scrapy项目 命令格式:scrapy st ...

  6. BSA Network Shell系列-scriptutil命令

    scriptutil ## 1 功能概述 scriptutil复制脚本到远程机的某个目录,然后在该目录执行脚本. 它的优点就是脚本是non-NSH的脚本.不支持NSH命令,执行起来的效果和runscr ...

  7. JavaScript之正则表达式(1)

    一,在线工具: regexper.com 二 ,正则示例: (1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)(1)( ...

  8. 第三方模块paramiko的使用

    "Paramiko" is a combination of the Esperanto words for "paranoid" and "frie ...

  9. sql集锦

    1. emp表中取出1981年入职的员工信息--sql select * from emp where extract(year from emp.hiredate)='1981'; ...陆续添加

  10. MP4大文件虚拟HLS分片技术,避免服务器大量文件碎片

    MP4大文件虚拟HLS分片技术,避免点播服务器的文件碎片 本文主要介绍了通过虚拟分片技术,把MP4文件,映射为HLS协议中的一个个小的TS分片文件,实现了在不实际切分MP4文件的情况下,通过HLS协议 ...