前段时间在开发中遇到这样的问题就时在A服务调用B服务时报了如下错:
Error while extracting response for type [java.util.List<java.util.Map<java.lang.String, java.lang.Object>>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Invalid JSON input: Cannot deserialize instance of java.util.ArrayList<java.util.Map<java.lang.String,java.lang.Object>>
out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<java.util.Map<java.lang.String,java.lang.Object>>
out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 1, column: 1]
红色箭头为A服务调用B服务的代码,当时在网上百度找了很久,大部分都说配置问题但是结合网上小伙伴们贴出的配置,然后对比我们服务的配置并没有发现我们服务在配置上有问题,最后通过不断的debug测试和排查将各种可能产生这种bug的可能原因排除的差不多,最后将目标锁定到第二张图片红色箭头的response上,最开始 response = ApiResult.class 是我们封装的一种固定返回json格式,当时我之所以没有怀疑是这个问题引起是因为这个是swarrge的注解应该不会影响返回的结果,但后来我将返回结果改成 ***response = List.class***后问题就处理好了。
![](https://img-blog.csdnimg.cn/20210627145852589.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyMzYzNTA2,size_16,color_FFFFFF,t_70
Error while extracting response for type [java.util.List<java.util.Map<java.lang.String,Object>>]
最新推荐文章于 2024-06-05 11:07:24 发布