接口调用出现类型转换错误,接收到数据为LinkedHashMap
cp.common.utils.JsonUtils : convertBean2Json FAILED, bean-class is null.
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.cp.service.db.entity.User
解决方案
List userList = xxxService.Method();
ObjectMapper mapper=new ObjectMapper();
userList = mapper.convertValue(xxxService.Method(), new TypeReference<List>(){});
importcom.fasterxml.jackson.core.type.TypeReference;
importcom.fasterxml.jackson.databind.ObjectMapper;