正经学徒,佛系记录,不搞事情
第一步:创建工具类
直接使用commons-beanutils实现对象拷贝,引入pom
commons-beanutils
commons-beanutils
1.9.3
创建工具类:BeanUtils
public class BeanUtils {
/**
* @param orig 源对象
* @param dest 目标对象
*/
public static void copyProperties(final Object orig,final Object dest){
try{
org.apache.commons.beanutils.BeanUtils.copyProperties(dest, orig);
}catch (Exception e){
throw new RuntimeException(e.getMessage());
}
}
/**
* @Description:拷贝list元素对象,将origs中的元素信息,拷贝覆盖至dests中
* @param origs 源list对象
* @param dests 目标list对象
* @param origsElementTpe 源list元素类型对象
* @param destElementTpe 目标list元素类型对象
* @param 源list元素类型
* @param 目标l