赞
踩
两个服务之间调用,由于粗心,遇到下面的错误
调用方
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);
}
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);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。