BeanUtils.copyProperties()方法引入不同包

两个对象之间拷贝相同的属性,可以使用BeanUtils.copyProperties()方法,

BeanUtils.copyProperties(obj1,obj2);

提示有三个包可选。

A,选择org.apache.commons......会提示Add throws declarations,即可能会出错。并且,这个包下的BeanUtils.copyProperties(obj1,obj2);是将

obj2拷贝到obj1.

B,选择org.springframework.......此时BeanUtils.copyProperties(obj1,obj2);是将obj1拷贝到obj2.

C,没有用过net.sf...hibernate.....下的这个方法。

posted @ 2017-06-26 17:18  昨日的世界  Views(493)  Comments(0Edit  收藏  举报