EntityUtils.java 483 B

1234567891011121314151617
  1. package com.migao.util;
  2. import org.springframework.beans.BeanUtils;
  3. public class EntityUtils {
  4. public static <T, E> E copyProperties(T source, Class<E> targetClass) {
  5. E targetEntity = null;
  6. try {
  7. targetEntity = targetClass.newInstance();
  8. BeanUtils.copyProperties(source, targetEntity);
  9. } catch (InstantiationException | IllegalAccessException e) {
  10. e.printStackTrace();
  11. }
  12. return targetEntity;
  13. }
  14. }