02--Activiti初始化表

初始化数据库

方法一:执行sql脚本文件activiti-5.13\database\create\activiti.mysql.create.*.sql文件


方法二:代码创建(有流程自然就有表)

package cn.miye.test;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;

public class TestActiviti {

    /** 使用代码创建工作流需要的23张表 */
    @Test
    public void createTable() {
        ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
                .createStandaloneProcessEngineConfiguration();
        // 连接数据库的配置
        processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
        processEngineConfiguration
                .setJdbcUrl("jdbc:mysql://localhost:3306/activiti?useUnicode=true&characterEncoding=utf8");
        processEngineConfiguration.setJdbcUsername("root");
        processEngineConfiguration.setJdbcPassword("root");

        /**
         * public static final String DB_SCHEMA_UPDATE_FALSE = "false";不能自动创建表,需要表存在
         * public static final String DB_SCHEMA_UPDATE_CREATE_DROP =
         * "create-drop";先删除表再创建表 public static final String DB_SCHEMA_UPDATE_TRUE =
         * "true";如果表不存在,自动创建表
         */
        processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        // 工作流的核心对象,ProcessEnginee对象
        ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
        System.out.println("processEngine:" + processEngine);
    }
}

 

 

方法三:使用配置文件:在类路径下创建Activiti.cfg.xml

package cn.miye.test;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;

public class TestActiviti {
    /** 使用配置文件创建工作流需要的23张表 */
    @Test
    public void createTable_2() {
        // ProcessEngineConfiguration processEngineConfiguration =
        // ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
        // //工作流的核心对象,ProcessEnginee对象
        // ProcessEngine processEngine =
        // processEngineConfiguration.buildProcessEngine();

        ProcessEngine processEngine = ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti.cfg.xml") //
                .buildProcessEngine();
        System.out.println("processEngine:" + processEngine);
    }
}

 

 

<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">
    <!--
             public static final String DB_SCHEMA_UPDATE_FALSE = "false";不能自动创建表,需要表存在
              public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";先删除表再创建表
              public static final String DB_SCHEMA_UPDATE_TRUE = "true";如果表不存在,自动创建表
   
        processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
     -->
    <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/itcast0711activiti?useUnicode=true&amp;characterEncoding=utf8"></property>
        <property name="jdbcUsername" value="root"></property>
        <property name="jdbcPassword" value="root"></property>
        <!-- 没有表创建表 -->
        <property name="databaseSchemaUpdate" value="true"></property>
    </bean>

</beans>

 

 

--1:资源库流程规则表
act_re_deployment --部署信息表
act_re_model --流程设计模型部署表
act_re_procdef --流程定义数据表
--2:运行时数据库表
act_ru_execution --运行时流程执行实例表
act_ru_identitylink --运行时流程人员表,主要存储任务节点与参与者的相关信息
act_ru_task --运行时任务节点表
act_ru_variable --运行时流程变量数据表
--3:历史数据库表
act_hi_actinst --历史节点表
act_hi_attachment --历史附件表
act_hi_comment --历史意见表
act_hi_identitylink --历史流程人员表
act_hi_detail --历史详情表,提供历史变量的查询
act_hi_procinst --历史流程实例表
act_hi_taskinst --历史任务实例表
act_hi_varinst --历史变量表
--4:组织机构表
act_id_group --用户组信息表
act_id_info --用户扩展信息表
act_id_membership --用户与用户组对应信息表
act_id_user --用户信息表
---这四张表很常见,基本的组织机构管理,关于用户认证方面建议还是自己开发一套,组件自带的功能太简单,使用中有很多需求难以满足
--5:通用数据表
act_ge_bytearray --二进制数据表
act_ge_property --属性数据表存储整个流程引擎级别的数据,初始化表结构时,会默认插入三条记录,

posted @ 2017-08-04 10:53  wdmiye  阅读(1378)  评论(0编辑  收藏  举报