Redis序列化存储对象

当报错如下时:

Could not write JSON: 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: com.chen.blog.domain.User$HibernateProxy$txqI31x8["$$_hibernate_interceptor"]); nested exception is 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: com.chen.blog.domain.User$HibernateProxy$txqI31x8["$$_hibernate_interceptor"])

如果国内论坛中提供的

@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })

没有解决,依旧报错,那么就可以确定不是因为空字段所造成的原因。
可以参考StrackOverflow该链接中的答案。

答案中指出,在使用hibernate时,提供的YourEntityClassRepositorie.getOne(id),需要修改成YourEntityClassRepositorie.findById(id).get(),即可解决。

具体原因,后期有空将进行追查。

你可能感兴趣的:(Java,java,redis)