当前位置: 代码迷 >> 综合 >> Activiti流程定义部署repositoryService.createDeployment()..addClasspathResource()...deploy()
  详细解决方案

Activiti流程定义部署repositoryService.createDeployment()..addClasspathResource()...deploy()

热度:94   发布时间:2023-11-24 02:37:34.0
/*** 流程定义的部署* activiti表有哪些?* act_re_deployment 部署信息act_re_procdef 流程定义的一些信息act_ge_bytearray 流程定义的bpmn文件及png文件*/
public class ActivitiDeployment {
    //流程定义部署public static void main(String[] args) {
    //1.创建ProcessEngine对象ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();//2.得到RepositoryService实例RepositoryService repositoryService = processEngine.getRepositoryService();//3.进行部署Deployment deployment = repositoryService.createDeployment().addClasspathResource("diagram/holiday01.bpmn")  //添加bpmn资源.addClasspathResource("diagram/holiday01.png").name("请假申请单流程2").deploy();//4.输出部署的一些信息System.out.println(deployment.getName());System.out.println(deployment.getId());}
}

zip包方式部署Activiti流程:

//流程定义部署 流程制作出来后要上传到服务器 zip文件更便于上传public static void main(String[] args) {
    //1.创建ProcessEngine对象ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();//2.得到RepositoryService实例RepositoryService repositoryService = processEngine.getRepositoryService();//3.转化出ZipInputStream流对象InputStream is = ActivitiDeployment.class.getClassLoader().getResourceAsStream("diagram/holiday.zip");//将 inputstream流转化为ZipInputStream流ZipInputStream zipInputStream = new ZipInputStream(is);//3.进行部署Deployment deployment = repositoryService.createDeployment().addZipInputStream(zipInputStream).name("请假申请单流程").deploy();//4.输出部署的一些信息System.out.println(deployment.getName());System.out.println(deployment.getId());}

activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"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.xsdhttp://www.springframework.org/schema/contex http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver" /><property name="url" value="jdbc:mysql://localhost:3306/activiti?useUnicode=true&amp;characterEncoding=UTF-8" /><property name="username" value="root" /><property name="password" value="123456" /><property name="maxActive" value="3" /><property name="maxIdle" value="1" /></bean><!--activiti单独运行的ProcessEngine配置,使用单独启动方式--><bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"><property name="dataSource" ref="dataSource"></property><property name="databaseSchemaUpdate" value="true"/></bean><!--<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"><property name="jdbcDriver" value="com.mysql.jdbc.Driver"/><property name="jdbcUrl" value="jdbc:mysql://localhost:3306/itcast0711activiti"/><property name="jdbcUsername" value="root"/><property name="jdbcPassword" value="root"/><property name="databaseSchemaUpdate" value="true"/></bean>-->
</beans>

在这里插入图片描述
下图表中有了一个新的流程定义:
在这里插入图片描述

  相关解决方案