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:资源文件表
来源:CSDN
作者:布衣牧羊
链接:https://blog.csdn.net/qq_36984455/article/details/104031366