ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
Flowable 有如下方式部署流程: ```java public interface DeploymentBuilder { DeploymentBuilder addInputStream(String var1, InputStream var2); DeploymentBuilder addClasspathResource(String var1); DeploymentBuilder addString(String var1, String var2); DeploymentBuilder addBytes(String var1, byte[] var2); DeploymentBuilder addZipInputStream(ZipInputStream var1); DeploymentBuilder addBpmnModel(String var1, BpmnModel var2); ``` <br/> **1. `addClasspathResource`方法部署** ```java @Test public void addClasspathResourceTest() { //获取引擎 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); //获取repositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); //部署流程 Deployment deployment = repositoryService.createDeployment() .addClasspathResource("bpmn/evectionDeployment.bpmn") .name("出差申请流程") .key("evectionDeployment") .category("业务类流程") .deploy(); //流程部署key: evectionDeployment System.out.println("流程部署key: " + deployment.getKey()); //流程类别: 业务类流程 System.out.println("流程类别: " + deployment.getCategory()); //流程部署Id: 90001 System.out.println("流程部署Id: " + deployment.getId()); //流程部署名称: 出差申请流程 System.out.println("流程部署名称: " + deployment.getName()); } ``` **2. `addZipInputStream`方法部署** `addZipInputStream`以压缩包的方式部署,可以一次性部署多个流程,它会自动扫描压缩包文件里面的`.bpmn`、`.xml`文件。 ```java @Test public void addZipInputStreamTest() { //获取流程引擎 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); //获取RepositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); //读取资源包文件 InputStream inputStream = this.getClass() .getClassLoader() //evectionZip.zip 中包含evectionZip001.bpmn、evectionZip002.bpmn 两个流程文件。 .getResourceAsStream("bpmn/evectionZip.zip"); ZipInputStream zipInputStream = new ZipInputStream(inputStream); //部署流程 Deployment deployment = repositoryService.createDeployment() .addZipInputStream(zipInputStream) .name("出差申请流程") .key("evectionZip") .category("业务类流程") .deploy(); //流程部署key: evectionZip System.out.println("流程部署key: " + deployment.getKey()); //流程类别: 业务类流程 System.out.println("流程类别: " + deployment.getCategory()); //流程部署Id: 100001 System.out.println("流程部署Id: " + deployment.getId()); //流程部署名称: 出差申请流程 System.out.println("流程部署名称: " + deployment.getName()); } ```