• Cannot deserialize instance of `java.util.ArrayList<org.jeecg.modules.face.entity.FaceDevice>` out of START_OBJECT token


    远程调用出现json解析异常

    操作失败,Error while extracting response for type [java.util.List<org.jeecg.modules.face.entity.FaceDevice>] and content type [application/json];
     nested exception is org.springframework.http.converter.HttpMessageNotReadableException: 
     JSON parse error: Cannot deserialize instance of `java.util.ArrayList<org.jeecg.modules.face.entity.FaceDevice>` out of START_OBJECT token; 
     nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: 
     Cannot deserialize instance of `java.util.ArrayList<org.jeecg.modules.face.entity.FaceDevice>` 
     out of START_OBJECT token
     at [Source: (PushbackInputStream); line: 1, column: 1]

    架构:微服务

    过程:

    在Feign调用别的服务的API方法时,出现了该异常,代码如下

    List<FaceDevice> ytSCameras = faceAPI.getDevicesByIds(ids);

    为了排除是API方法报错,所以不通过feign调用,通过直接调用该API方法

     /***
         * 根据id集合查人脸设备face_device
         * @param ids
         * @return
         */
        @GetMapping("/face/api/getDevicesByIds")
        List<FaceDevice> getDevicesByIds(@RequestParam("ids") List<String> ids);

    测试通过,方法没有问题,那就说明是远程调用的问题

    json解析异常,这个方法没有json参数啊,难道远程调用是用json的格式传递的?在网上查了好多也没有解决方式。

    java.util.ArrayList<org.jeecg.modules.face.entity.FaceDevice>

    看到这一行,但API方法的返回值是List,于是我将API的返回值改为ArrayList

    果然,不再报异常

    
    
      /***
         * 根据id集合查人脸设备face_device
         * @param ids
         * @return
         */
        @GetMapping("/face/api/getDevicesByIds")
        ArrayList<FaceDevice> getDevicesByIds(@RequestParam("ids") List<String> ids);
    
    

    虽然小编蒙对了,但具体是什么原因,小编也想不明白,有哪位聪明的同学能想明白的话,在评论里告诉我哦!

     

     

  • 相关阅读:
    PHP基础知识(十一)
    PHP基础知识(十)
    PHP基础知识(九)
    PHP中禁用cookie后session的实现
    PHP基础知识(八)
    将博客搬至CSDN
    如何为预先数据库创建自定义SQL Server复制
    数据库同步工具
    如何终止与MySQL数据库的某些连接
    从Oracle到SQL Server和从SQL Server到Oracle的迁移指南
  • 原文地址:https://www.cnblogs.com/rachelgarden/p/14656583.html
Copyright © 2020-2023  润新知