第一步:创建工具类
直接使用commons-beanutils实现对象拷贝,引入jar
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
第二步:创建工具类: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对象
* &