ResponseEntity Spring Boot中的类型定义错误

问题描述 投票:0回答:1

我有2个微服务:网关和另一个,与Feign连接。

当我直接向微服务请求时,我的响应正常。但是如果我用网关来做的话我有例外:

Type definition error: [simple type, class FieldsDTO]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `FieldsDTO` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

这是我的DTO课程:

@Data
@NoArgsConstructor
@AllArgsConstructor
public class FieldsDTO {
    private Set<String> fieldNames;
    private List<ShortFiledsDTO> dataList;
}

是否有想法解决该问题?

java spring-boot spring-cloud-feign
1个回答
0
投票

[尝试删除Lombok批注-@NoArgsConstructor@AllArgsConstructor。而是为所有&无参数构造函数添加代码。

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.