使用BeanUtils.BeanUtils.copyProperties解决你的烦恼!
BeanUtils.copyProperties(order, keOrderVo);
- 使用BeanUtils.copyProperties方法的原因:
- 代码中大量重复的setXXX方法,使得代码臃肿不堪;
- 代码量大,增加打码时间;
- 方法功能阅读困难;
- 使用方法:
将订单中的数据映射到订单VO中
KeOrder order = this.getById(orderId);
Assert.notNull(order,"订单不存在");
KeOrderVo keOrderVo = new KeOrderVo();
BeanUtils.copyProperties(order, keOrderVo);
本文介绍如何使用BeanUtils的copyProperties方法简化实体类之间的属性映射,避免手动编写大量setXXX方法,提高代码可读性和开发效率。
3518

被折叠的 条评论
为什么被折叠?



