public static <T> List<T> copyBeanList(List<?> resourceList, Class<T> target) { List<T> targetList = new LinkedList<>(); if (CollectionUtils.isEmpty(resourceList)) { return targetList; } resourceList.forEach(e -> { T o = null; try { o = target.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { ex.printStackTrace(); } org.springframework.beans.BeanUtils.copyProperties(e, o); targetList.add(o); }); return targetList; }
BeanUtils拷贝对象List
最新推荐文章于 2024-06-12 11:52:40 发布