1.activiti7 流程部署

it2026-04-06  4

package com.imooc.activitiweb; import org.activiti.engine.RepositoryService; import org.activiti.engine.repository.Deployment; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.io.InputStream; import java.util.List; import java.util.zip.ZipInputStream; @SpringBootTest public class Part1_Deployment { @Autowired private RepositoryService repositoryService; //通过bpmn部署流程 @Test public void initDeploymentBPMN(){ String filename="BPMN/Part4_Task_claim.bpmn"; // String pngname="BPMN/Part1_Deployment.png"; Deployment deployment=repositoryService.createDeployment() .addClasspathResource(filename) //.addClasspathResource(pngname)//图片 .name("流程部署测试候选人task") .deploy(); System.out.println(deployment.getName()); } //通过ZIP部署流程 @Test public void initDeploymentZIP() { InputStream fileInputStream = this.getClass() .getClassLoader() .getResourceAsStream("BPMN/Part1_DeploymentV2.zip"); ZipInputStream zip=new ZipInputStream(fileInputStream); Deployment deployment=repositoryService.createDeployment() .addZipInputStream(zip) .name("流程部署测试zip") .deploy(); System.out.println(deployment.getName()); } //查询流程部署 @Test public void getDeployments() { List<Deployment> list = repositoryService.createDeploymentQuery().list(); for(Deployment dep : list){ System.out.println("Id:"+dep.getId()); System.out.println("Name:"+dep.getName()); System.out.println("DeploymentTime:"+dep.getDeploymentTime()); System.out.println("Key:"+dep.getKey()); } } }

执行完部署流程,会在这两个表生成数据。

最新回复(0)