SpringBoot2.X整合mybatis过程中出现的问题,如下所示:
org.springframework.http.converter.HttpMessageNotWritableException: Could not write
content: Noserializer found for class com.google.common.cache.CacheStats and no properties
discovered to createBeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
分析问题:
导致以上问题主要是使用@ResponseBody序列化是结果值为 null 导致。
处理办法:
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
处理来源:
https://bbs.youkuaiyun.com/topics/392176341
学习参考:
https://blog.youkuaiyun.com/sdyy321/article/details/40298081