解决方式一 加注解
解决,在实体上添加注解
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})// 处理因为部分内容没有值,引发的序列化错误
解决方式二 统一配置
spring:
jackson:
serialization:
FAIL_ON_EMPTY_BEANS: false
其内部有一个枚举SerializationFeature
其中有一段描述

这种方式统一解决,不过返回的值里面会多一样。

网友评论