FeignClient接口格式
FeignClient接口格式 报错信息: {"timestamp":1648015711758,"status":404,"error":"Not Found","message":"No message available","path":"/getDto"}
/order/getDto 完整的地址。
2022-03-23 14:45:40.188 [SimpleAsyncTaskExecutor-1] ERROR [03964e0b1ec5783d,03964e0b1ec5783d] o.s.a.i.SimpleAsyncUncaughtExceptionHandler#handleUncaughtException [line:38] - Unexpected error occurred invoking async method: xxx java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to XXXDTO
代码语言:javascript代码运行次数:0运行复制//标准写法
@FeignClient(name="order-api")
public interface FeignTestService {
@GetMapping("/order/getDto") //url必须要完整
public ResponseData<OrderDTO> getOrderDto(@RequestParam(value = "orderNo") String orderNo); //ResponseData后面的泛型带上类型,避免调用方接收需要类型转换
}
@Data
public class ResponseData<T> {
@AutoDocProperty(value = "返回代码")
private String resCode;
@AutoDocProperty(value = "返回消息")
private String resMsg;
@AutoDocProperty(value = "返回实体")
private T data;
}
// LinkedHashMap hashMap = (LinkedHashMap) responseData.getData();
//json转对象
// OrderDTO dto = JSON.parseObject(JSON.toJSONString(hashMap), OrderDTO.class);
//正确的接收方法:
OrderDTO dto = responseData.getData();
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2022-03-23,如有侵权请联系 cloudcommunity@tencent 删除对象泛型接口privatepublic发布者:admin,转转请注明出处:http://www.yc00.com/web/1754987918a5224388.html
评论列表(0条)