/** * 部署单个流程定义 * * @param resourceLoader {@link ResourceLoader} * @param processKey 模块名称 * @throws IOException 找不到zip文件时 */ private void deploySingleProcess( ResourceLoader resourceLoader, String processKey, String exportDir) throws IOException { String classpathResourceUrl = "classpath:/deployments/" + processKey + ".bar"; logger.debug("read workflow from: {}", classpathResourceUrl); Resource resource = resourceLoader.getResource(classpathResourceUrl); InputStream inputStream = resource.getInputStream(); if (inputStream == null) { logger.warn("ignore deploy workflow module: {}", classpathResourceUrl); } else { logger.debug("finded workflow module: {}, deploy it!", classpathResourceUrl); ZipInputStream zis = new ZipInputStream(inputStream); Deployment deployment = repositoryService.createDeployment().addZipInputStream(zis).deploy(); // export diagram List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list(); for (ProcessDefinition processDefinition : list) { WorkflowUtils.exportDiagramToFile(repositoryService, processDefinition, exportDir); } } }