BeanUtils.copyProperties 与 PropertyUtils.copyProperties 都是拷贝对象属性的方法.
BeanUtils 支持类型转换,而 PropertyUtils 不支持。但是 BeanUtils 不允许对象的属性值为 null,PropertyUtils 可以拷贝属性值 null 的对象。
如果对象属性值为 null,
BeanUtils.copyProperties 方法会报 commons.beanutils.ConversionException: No value specified 错误。
本文探讨了BeanUtils与PropertyUtils两种对象属性拷贝方法的区别。BeanUtils支持类型转换但不允许属性值为null,否则会抛出ConversionException错误;而PropertyUtils则允许拷贝属性值为null的对象。
567

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



