Copy specific fields by using BeanUtils.copyProperties?

前端 未结 5 1882
执笔经年
执笔经年 2020-12-12 14:13

springframework.beans.BeanUtils is very useful to copy objects, and I use the \"ignoreProperties\" option frequently. However, sometimes I want to copy only spe

5条回答
  •  攒了一身酷
    2020-12-12 14:27

    Check this out: BeanPropertyCopyUtil.

    Example:

    copyProperties(user, systemUser, "first firstName", "last lastName");
    

    You'll also need Apache Commons BeanUtils.

提交回复
热议问题