微服务bug之:openFeign远程调用返回类型转换异常
![](https://img2022.cnblogs.com/blog/2590254/202204/2590254-20220428172106269-1619073163.png)
楼主是在使用easyexcel导出的时候,获取数据出现这个错误,因为Spring底层是这样处理的使用LinkedhashMap来承接查询结果,导致转换异常
public List<NeedAllocationEntity> getNeedAllocationData() { //查询数据 Result<PageUtils> result = needAllocationService.list(new HashMap<>(1 << 4)); //将list取出,获取转换对象的集合 return result.getData().getList().stream() .map(e -> JSON.parseObject(JSON.toJSONString(e), new TypeReference<NeedAllocationEntity>() { })) .collect(Collectors.toList()); }
解决办法是使用JSON进行转换,先转为string,在转为后面指定的对象
本文来自博客园,作者:程序员hg,转载请注明原文链接:https://www.cnblogs.com/hg-blogs/p/16203742.html