activiti7关联mysql_Activiti7工作流引擎环境搭建

Activiti7工作流引擎环境搭建

在IEDA中添加actiBPM插件

file -->>Settings -->> Plugins -->> actiBPM

添加Activiti所需的jar包

activiti-engine-7.0.0.beta1.jar

activiti 依赖的 jar 包:mybatis、alf4j、log4j 等

activiti 依赖的 spring 包

数据库驱动

第三方数据连接池 dbcp

单元测试 Junit-4.12.jar

我们使用 maven 来实现项目的构建,所以应当导入这些 jar 所对应的坐标到 pom.xml 文件中。

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.hellogitee.activiti

activiti01

1.0-SNAPSHOT

1.6.6

1.2.12

org.activiti

activiti-engine

7.0.0.Beta1

org.activiti

activiti-spring

7.0.0.Beta1

org.activiti

activiti-bpmn-model

7.0.0.Beta1

org.activiti

activiti-bpmn-converter

7.0.0.Beta1

org.activiti

activiti-json-converter

7.0.0.Beta1

org.activiti

activiti-bpmn-layout

7.0.0.Beta1

org.activiti.cloud

activiti-cloud-services-api

7.0.0.Beta1

mysql

mysql-connector-java

5.1.40

junit

junit

4.12

log4j

log4j

${log4j.version}

org.slf4j

slf4j-api

${slf4j.version}

org.slf4j

slf4j-log4j12

${slf4j.version}

org.mybatis

mybatis

3.4.5

commons-dbcp

commons-dbcp

1.4

数据库中添加activiti表

CREATE DATABASE activiti

添加log4j 配置文件

在src-->main-->resources目录下添加配置文件 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=/home/aj/axis.log

log4j.appender.LOGFILE.Append=true

log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout

log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601}[%15.15t] %-5p %30.30c %x - %m\n

添加activiti配置文件

在src-->main-->resources 目录下添加配置文件 activiti.cfg.xml

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">

关于 processEngineConfiguration 中的 databaseSchemaUpdate 参数,通过此参数设计 activiti

数据表的处理策略,参数如下:

false(默认):检查数据库表的版本和依赖库的版本, 如果版本不匹配就抛出异常。

true: 构建流程引擎时,执行检查,如果需要就执行更新。 如果表不存在,就创建。

create-drop: 构建流程引擎时创建数据库表, 关闭流程引擎时删除这些表。

drop-create:先删除表再创建表。

create: 构建流程引擎时创建数据库表, 关闭流程引擎时不删除这些表。

测试程序

package com.hellogitee.test;

import org.activiti.engine.ProcessEngine;

import org.activiti.engine.ProcessEngineConfiguration;

import org.activiti.engine.ProcessEngines;

import org.junit.Test;

/**

* 测试类

* 作用:测试activiti所需要的25张表的生成

*/

public class ActivitiTest {

@Test

public void testGenTable1(){

//条件: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","processEngineConfiguration");

//2.创建ProcesEngine对象

ProcessEngine processEngine = configuration.buildProcessEngine();

//3.输出processEngine对象

System.out.println(processEngine);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值