Activiti系列(二)部署流程

北慕城南 提交于 2020-01-22 01:23:18

1.下载activiti 6.0

官网地址:https://www.activiti.org/get-started

官网下载不动的话,百度云资源链接:https://pan.baidu.com/s/1_D47-i4bTHymYnHBE2lIgw

 下载解压之后的目录如下:

2.部署流程 

1)先画流程图,基于上文的流程图,参考 画流程图

2)加载流程图。

去activiti下面找需要的依赖和文件:

建立项目,复制jar包:

开始编写部署流程图的代码:

package com.act.demo;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.junit.Test;

/**
 * 部署流程
 * 
 * @author JiangTeJie
 *
 */
public class DeployDemo {

	ProcessEngine init() {
		// 创建一个流程配置对象
		ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration
				.createStandaloneProcessEngineConfiguration();
		processEngineConfiguration.setJdbcDriver("com.mysql.jdbc.Driver");
		processEngineConfiguration.setJdbcUrl(
				"jdbc:mysql://localhost:3306/activiti?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=utf8");
		processEngineConfiguration.setJdbcUsername("root");
		processEngineConfiguration.setJdbcPassword("123456");
		// 设置数据库建表策略
		processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
		// 创建一个流程对象
		return processEngineConfiguration.buildProcessEngine();
	}

	/// 1.jdbc方式部署
	@Test
	public void jdbcDeployTest() {
		ProcessEngine processEngine = init();
		System.out.println("构建ProcessEngine:" + processEngine);

		/// 获取仓库服务,获取仓库构建对象,然后发布流程
		RepositoryService repositoryService = processEngine.getRepositoryService();
		DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name("简单流程");
		deploymentBuilder.addClasspathResource("HelloWorld.bpmn").addClasspathResource("HelloWorld.png");
		// 部署
		Deployment deployment = deploymentBuilder.deploy();
		System.out.println("部署流程Id:" + deployment.getId());
		System.out.println("部署流程名称:" + deployment.getName());
		System.out.println("部署时间:" + deployment.getDeploymentTime());
	}

	/// 删除部署
	@Test
	public void deleteDeploy() {
		ProcessEngine processEngine = init();
		System.out.println("构建ProcessEngine:" + processEngine);
		
		///根据id删除
		processEngine.getRepositoryService().deleteDeployment("1");
		System.out.println("删除完毕");
	}
}

3)添加和删除流程 会 操作这三张表:

  • act_re_deployment:部署对象表
  • act_re_procdef:流程定义表
  • act_ge_bytearray:资源文件表

 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!