java.lang.IllegalArgumentException: Source must not be null

墨蓝 2024-03-23 11:51 200阅读 0赞

ProductManagementAppEntity entity = Mapper.selectOne(
new QueryWrapper().eq(“id”, id));
Resp resp=new Resp();
if (entity != null){
BeanUtil.copyProperties(entity,resp);
}
return ResponseUtil.ok(resp);

我的这个错误原因在于查询数据库没有查到数据,返回值为空,使用工具转换时异常了。如果是自己封装的类转换工具类的话,记得把判空加上。

发表评论

表情:
评论列表 (有 0 条评论,200人围观)

还没有评论,来说两句吧...

相关阅读