BeanCopy { public static void copyProperties(Object src, Object dest) { if (ObjectUtil.isAnyNull(src, dest)) { return; } Class<?> srcClazz = src.getClass(); Field[] destFields = fieldCache.getInstanceFields(dest.getClass()); for (Field field : destFields) { if (ReflectionUtil.isFinal(field)) { continue; } Field srcField = fieldCache.getInstanceField(srcClazz, field.getName()); if (srcField != null) { Object value = ReflectionUtil.readField(srcField, src); ReflectionUtil.writeField(field, dest, value); } } }  static void copy(Object src, Object dest, boolean useAnnotation); static void copyProperties(Object src, Object dest); static void copyByAnnotation(Object src, Object dest); static void copyByMethod(Object src, Object dest);  }
@Test public void copyProperties() { Abean bean = new Abean(); bean.setFooProp("ggg"); Abean acopied = new Abean(); BeanCopy.copyProperties(bean, acopied); Assert.assertEquals("ggg", acopied.getFooProp()); Cbean src = new Cbean(); src.setS2("11111"); src.setS3("aaaaa"); Cbean dest = new Cbean(); BeanCopy.copyProperties(src, dest); Assert.assertEquals("aaaaa", dest.getS3()); logger.info(dest); }