Activiti 部署流程定义及相关的表(classpath部署zip部署)

Posted 纸上得来终觉浅,绝知此事要躬行

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Activiti 部署流程定义及相关的表(classpath部署zip部署)相关的知识,希望对你有一定的参考价值。

 

package com.mycom.processDefinition;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

public class ProcessDefinitionTest {

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    
    /*
     *部署流程定义 (从classpath)
     */
    @Test
    public void deploymentProcessDefinition(){
        Deployment deployment = processEngine.getRepositoryService()//与流程定义和部署对象相关的Service
                        .createDeployment()//创建一个部署对象
                        .name("流程定义")//添加部署名称
                        .addClasspathResource("diagrams/HelloWorld.bpmn")//从classpath的资源中加载,一次只能加载一个文件
                        .addClasspathResource("diagrams/HelloWorld.png")
                        .deploy();//完成部署
        System.out.println("部署ID:"+deployment.getId());
        System.out.println("部署名称:"+deployment.getName());
        
    }
    
    
}

 SELECT * FROM activiti.act_re_deployment a; #部署对象表

 SELECT * FROM activiti.act_re_procdef a; #流程定义表

 SELECT * FROM activiti.act_ge_bytearray a;# 资源文件表

 

SELECT * FROM activiti.act_ge_property a; #主键生成策略表

 

 

上面是classpath部署,下面是zip部署

 

 

package com.mycom.processDefinition;

import java.io.InputStream;
import java.util.zip.ZipInputStream;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;

public class ProcessDefinitionTest {

    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    
    /*
     *部署流程定义 (从classpath)
     */
    @Test
    public void deploymentProcessDefinition_classpath(){
        Deployment deployment = processEngine.getRepositoryService()//与流程定义和部署对象相关的Service
                        .createDeployment()//创建一个部署对象
                        .name("流程定义")//添加部署名称
                        .addClasspathResource("diagrams/HelloWorld.bpmn")//从classpath的资源中加载,一次只能加载一个文件
                        .addClasspathResource("diagrams/HelloWorld.png")
                        .deploy();//完成部署
        System.out.println("部署ID:"+deployment.getId());
        System.out.println("部署名称:"+deployment.getName());
        
    }
    
    /*
     *部署流程定义 (从zip)
     */
    @Test
    public void deploymentProcessDefinition_zip(){
        InputStream in = this.getClass().getClassLoader().getResourceAsStream("diagrams/HelloWorld.zip");
        ZipInputStream zipInputStream = new ZipInputStream(in);
        Deployment deployment = processEngine.getRepositoryService()//与流程定义和部署对象相关的Service
                        .createDeployment()//创建一个部署对象
                        .name("流程定义")//添加部署名称
                        .addZipInputStream(zipInputStream)//完成zip文件的部署
                        .deploy();//完成部署
        System.out.println("部署ID:"+deployment.getId());
        System.out.println("部署名称:"+deployment.getName());
        
    }
}

 

以上是关于Activiti 部署流程定义及相关的表(classpath部署zip部署)的主要内容,如果未能解决你的问题,请参考以下文章

2017.2.28 activiti实战--第五章--用户与组及部署管理部署流程资源

activiti全部知识点

Activiti_Activiti核心数据表的作用

工作流Activiti表说明

我activiti 部署流程 为啥有一个表没有插入数据

Spring中部署Activiti流程定义的三种姿势