获取不到商品列表
我先用2016.02版本的IDEA,下面代码报错:
@Override public List<ItemModel> listItem() { List<ItemDO> itemDOList = itemDOMapper.listItem(); //使用Java8的stream API List<ItemModel> itemModelList = itemDOList.stream().map(itemDO -> { ItemStockDO itemStockDO = itemStockDOMapper.selectByItemId(itemDO.getId()); ItemModel itemModel = this.convertModeFromDataObject(itemDO, itemStockDO); return itemModel; }).collect(Collectors.toList()); return itemModelList; }
于是,换到2019.01版本的IDEA,同样报错,根据idea的提示,把代码改成了:
@Override public List<ItemModel> listItem() { List<ItemDO> itemDOList = itemDOMapper.listItem(); //使用Java8的stream API List<ItemModel> itemModelList = (List<ItemModel>) itemDOList.stream().map(itemDO -> { ItemStockDO itemStockDO = itemStockDOMapper.selectByItemId(itemDO.getId()); ItemModel itemModel = this.convertModeFromDataObject(itemDO, itemStockDO); return itemModel; }).collect(Collectors.toList()); return itemModelList; }
错误消失了,但是 http://localhost:8090/item/list 获取不到商品列表,根据其他同学的提问,说是item表和item_stock表的数据不匹配,我这里的数据是匹配的,还是报错:
status | "fail" |
data | |
errCode | 10002 |
errMsg | "未知错误" |
可怜,新手,不会debug,不知道怎么排错......