Cannot deserialize instance of `java.util.ArrayList ` 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\n 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);
 
        

雖然小編蒙對了,但具體是什么原因,小編也想不明白,有哪位聰明的同學能想明白的話,在評論里告訴我哦!

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM