BeanUtils

属性拷贝
BeanUtils.copyProperties(a, b);

注意
在不同的包下面,拷贝顺序相反

org.springframework.beans.BeanUtils

表示,a拷贝到b
BeanUtils工具的使用

org.apache.commons.beanutils.BeanUtils

表示,b拷贝到a
BeanUtils工具的使用使用方式

导入对应的包,直接使用

import org.springframework.beans.BeanUtils;
BeanUtils.copyProperties(sample, sampleExt);

或者
import org.apache.commons.beanutils.BeanUtils;
BeanUtils.copyProperties(sample, sampleExt);

相关文章: