关闭spring boot jackson的FAIL_ON_EMPTY_BEANS

异常信息:

No serializer found for class org.springframework.cache.interceptor.SimpleKey and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.cache.interceptor.SimpleKey and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

分析异常信息:

没有找到 serializer 

解决办法:

1. https://www.jianshu.com/p/1eb0929503e1
生成一个ObjectMapper.


2. https://stackoverflow.com/questions/28862483/spring-and-jackson-how-to-disable-fail-on-empty-beans-through-responsebody/28862597
bootstrap.yml 里加个选项:spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false

猜你喜欢

转载自www.cnblogs.com/Schmidt/p/9258667.html
今日推荐