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

两个对象之间拷贝相同的属性,可以使用BeanUtils.copyProperties()方法,
BeanUtils.copyProperties(obj1,obj2);
提示有三个包

  1. 选择org.apache.commons……会提示Add throws declarations,即可能会出错。并且,这个包下的BeanUtils.copyProperties(obj1,obj2);是将obj2拷贝到obj1.
  2. 选择org.springframework…….此时BeanUtils.copyProperties(obj1,obj2);是将obj1拷贝到obj2.(常用)
  3. 没有用过net.sf…hibernate…..下的这个方法。