首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用SpingBoot 2.7.3和可流动的6.7.2获得流程?

如何使用SpingBoot 2.7.3和可流动的6.7.2获得流程?
EN

Stack Overflow用户
提问于 2022-09-05 07:12:33
回答 1查看 98关注 0票数 0

我有一个财务总监:

代码语言:javascript
复制
@RestController
@RequestMapping("processes")
public class ProcessController {
    @Autowired
    private ProcessEngine processEngine;

    @Autowired
    private RepositoryService repositoryService;

    @GetMapping
    public List<ProcessDefinition> listProcess() {
        return processEngine.getRepositoryService().createProcessDefinitionQuery().list();
    }

    @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Deployment addProcess(@RequestPart MultipartFile file) throws IOException {
        return repositoryService.createDeployment().addInputStream(file.getOriginalFilename(), file.getInputStream()).deploy();
    }
}

我已经上传了test.bpmn20.xmladdProcess()方法,但是当我想要获得带有listProcess方法的ProcessDefinition列表时,控制台警告:

代码语言:javascript
复制
Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Cannot invoke "org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.getIdentityLinkServiceConfiguration()" because "processEngineConfiguration" is null; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Cannot invoke "org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.getIdentityLinkServiceConfiguration()" because "processEngineConfiguration" is null (through reference chain: java.util.ArrayList[0]->org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl["identityLinks"])]

我的POM.xml:

代码语言:javascript
复制
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-spring-boot-starter</artifactId>
      <version>6.7.2</version>
    </dependency>

为什么控制台警告这个?我能做什么?

请帮帮我,塞克斯!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-05 08:52:27

要从Spring中的REST端点返回变量,需要将变量转换为JSON。但是,可流动API响应没有优化以转换为DTO。这就是为什么您可能无法将它们直接作为响应变量返回。

例如:

代码语言:javascript
复制
@RestController
@RequestMapping("processes")
public class ProcessController {
    @Autowired
    private ProcessEngine processEngine;

    @Autowired
    private RepositoryService repositoryService;

    // ...

    @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public DeploymentDto addProcess(@RequestPart MultipartFile file) throws IOException {
        Deployment deployment = repositoryService.createDeployment()
                .addInputStream(file.getOriginalFilename(), file.getInputStream())
                .deploy();
        return new DeploymentDto(deployment);
    }

    private static class DeploymentDto {
        private final String id;
        private final String name;

        public DeploymentDto(Deployment deployment) {
            this.id = deployment.getId();
            this.name = deployment.getName();
        }

        public String getId() {
            return id;
        }

        public String getName() {
            return name;
        }
    }
}

您可以创建自己的DTO对象,并将可流动API的结果映射到DTO。或者,您可以使用flowable-spring-boot-starter-rest依赖项,它为您提供开箱即用的REST端点。那里的映射会自动为您处理。(有关更多信息,https://www.flowable.com/open-source/docs/bpmn/ch05a-Spring-Boot/#getting-started,请参阅入门指南)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73605718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档