我有一个财务总监:
@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.xml和addProcess()方法,但是当我想要获得带有listProcess方法的ProcessDefinition列表时,控制台警告:
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:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.7.2</version>
</dependency>为什么控制台警告这个?我能做什么?
请帮帮我,塞克斯!
发布于 2022-09-05 08:52:27
要从Spring中的REST端点返回变量,需要将变量转换为JSON。但是,可流动API响应没有优化以转换为DTO。这就是为什么您可能无法将它们直接作为响应变量返回。
例如:
@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,请参阅入门指南)
https://stackoverflow.com/questions/73605718
复制相似问题