org.springframework.beans.BeanUtils.copyProperties对象赋值的常见问题

2024-10-09 08:28:27 浏览数 (21)

org.springframework.beans.BeanUtils.copyProperties对象赋值的常见问题

//code public static void copyProperties(Object source, Object target) throws BeansException { copyProperties(source, target, null, (String[]) null); }

//支付金额 private Integer amt; //支付金额 private Integer payAmt;

//手机号 private Long mobile; //手机号 private String mobile;

BeanUtils.copyProperties在做对象赋值的时候,需要考虑常见的两类情况,1:字段名称不一致,2:字段名相同但是数据类型不同的情况。 导致引起数据报空指针或业务逻辑数据错误。

0 人点赞