当前位置:   article > 正文

feign.codec.DecodeException

feign.codec.decodeexception

两个服务之间调用,由于粗心,遇到下面的错误
调用方
feign.codec.DecodeException: Error while extracting response for type [java.util.List] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token
at [Source: (PushbackInputStream); line: 1, column: 1]

被调用方demo服务
java.lang.IllegalStateException: No primary or default constructor found for interface java.util.List
问题出现的原因是demo服务的接口确少 @RequestParam(name = “ids”, required = true)

@FeignClient(name="demo")
public interface IUserController{
	
	@RequestMapping(value = "/test",method = RequestMethod.GET)
	List<User> findUserListByIds(@RequestParam("ids") List<Long> ids);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

demo服务的controller写下如下代码即可

 @RequestMapping(value = "/test", method = RequestMethod.GET)
 public List<User> findUserListByIds(@ApiParam(value = "ids",name = "用户id") @RequestParam(name = "ids", required = true) List<Long> ids) {

        return userService.findUserListByIds(ids);
 }
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号