1. 项目结构
2. 指定zip格式的文件完成部署
/**
* 部署流程定义(从zip)
*/
@Test
public void deploymentProcessDefinition_zip(){
InputStream in = this.getClass().getClassLoader().getResourceAsStream("diagrams/helloworld.zip");
ZipInputStream zipInputStream = new ZipInputStream(in);
//与流程定义和部署相关的service
RepositoryService repositoryService = processEngine.getRepositoryService();
//创建一个部署对象
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
//添加部署的名称
deploymentBuilder.name("流程定义");
//指定zip格式的文件完成部署
deploymentBuilder.addZipInputStream(zipInputStream);
//完成部署
Deployment deployment = deploymentBuilder.deploy();
System.out.println("部署id:"+deployment.getId());
System.out.println("部署名称:"+deployment.getName());
}
3. 部署流程定义(从classpath)
/**
* 部署流程定义(从classpath)
*/
@Test
public void deploymentProcessDefinition_classpath(){
//与流程定义和部署相关的service
RepositoryService repositoryService = processEngine.getRepositoryService();
//创建一个部署对象
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
//添加部署的名称
deploymentBuilder.name("流程定义");
//从classpath资源中加载,一次只能加载一个
deploymentBuilder.addClasspathResource("diagrams/helloworld.bpmn");
deploymentBuilder.addClasspathResource("diagrams/helloworld.png");
//完成部署
Deployment deployment = deploymentBuilder.deploy();
System.out.println("部署id:"+deployment.getId());//501
System.out.println("部署名称:"+deployment.getName());//流程定义
}