目录

Error-while-extracting-response-for-type-java.util.Listjava.util.Mapjava.lang.String,Object

目录

Error while extracting response for type [java.util.List<java.util.Map<java.lang.String,Object>>]

前段时间在开发中遇到这样的问题就时在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://i-blog.csdnimg.cn/blog_migrate/d777195738a2da7178fe34dceffa5b50.png

![]( https://i-blog.csdnimg.cn/blog_migrate/c7cc67c8cd35baefe8346fe1cc6f40fa.png