How to copy properties from one Java bean to another?

前端 未结 8 1426
Happy的楠姐
Happy的楠姐 2020-12-17 15:53

I have a simple Java POJO that I would copy properties to another instance of same POJO class.

I know I can do that with BeanUtils.copyProperties() but I would like

8条回答
  •  旧时难觅i
    2020-12-17 16:24

    I guess if you look at the source code of BeanUtils, it will show you how to do this without actually using BeanUtils.

    If you simply want to create a copy of a POJO (not quite the same thing as copying the properties from one POJO to another), you could change the source bean to implement the clone() method and the Cloneable interface.

提交回复
热议问题