日常Exception第二十八回:com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitio
Posted 善良勤劳勇敢而又聪明的老杨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了日常Exception第二十八回:com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitio相关的知识,希望对你有一定的参考价值。
热门系列:
1、问题
报错信息:com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "tcount": xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params) vs xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params)
2021-07-13 09:28:54,615 [http-nio-8302-exec-1] WARN (CompositeLog.java:127)- Failed to evaluate Jackson deserialization for type [[simple type, class xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "tcount": xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params) vs xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params)
2021-07-13 09:28:54,616 [http-nio-8302-exec-1] WARN (CompositeLog.java:127)- Failed to evaluate Jackson deserialization for type [[simple type, class xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "tcount": xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params) vs xxx.xxx.xxx.xxx.xxx.GroupStateRequestBean#setTcount(1 params)
2021-07-13 09:28:54,624 [http-nio-8302-exec-1] ERROR (GlobalExceptionHandler.java:143)- exception:
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:225)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:158)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:131)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
2、问题分析
先看一下报错类的信息截图:
报错原因:如果bean 中有定义两个 同名方法,如果jackson反序列化过程中,不能正常识别,就会出现上述异常。
3、解决方法
在其中一个方法上加上注解@JsonIgnore,不参于序列化,即可解决!
若有问题,欢迎下方留言讨论~~~~
以上是关于日常Exception第二十八回:com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitio的主要内容,如果未能解决你的问题,请参考以下文章
一起Talk Android吧(第二百九十八回:Android中的BLE开发:大结局)
一起Talk Android吧(第四百二十八回:在Android中使用MQTT通信二)
一起Talk Android吧(第三百二十八回:Android中网络通信之UPD概述)
日常Exception第二十六回:RedisSystemException...RejectedExecutionException: event executor terminated
日常Exception第二十六回:RedisSystemException...RejectedExecutionException: event executor terminated