问题描述:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.HashMap["data"]->com.dahaiwuliang.code.entity.ArcType$HibernateProxy$0zgDD1TD["hibernateLazyInitializer"])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) ~[jackson-databind-2.10.0.jar:2.10.0]
at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1191) ~[jackson-databind-2.10.0.jar:2.10.0]
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:403) ~[jackson-databind-2.10.0.jar:2.10.0]
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:71) ~[jackson-databind-2.10.0.jar:2.10.0]
在做资源修改的时候,出现序列化错误,查看博客发现SpringBoot对JSON解析有严格的要求,我开始以为是实体类有些值为NULL转换为JSON时报错,不过在我加了
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
忽略为空的值时候,还是报错。
##后面才在application.properties文件中添加以下代码行解决问题,不过还是有点疑惑,前面的方法为什么不行,希望有人解答。
spring.jackson.serialization.fail-on-empty-beans=false
以下是文章参考链接
https://codingdict.com/questions/36339
版权声明:本文为wangzixu_原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。