使用BeanUtils.copyProperties(source,target);方法
(BeanUtils.copyProperties()方法是淺拷貝)
//我要把PrjPlanDetailEntity 對象的數據拷貝到 PrjBdgDetailEntity,只要他們有相同的字段,數據就會拷貝過去
PrjPlanDetailEntity p1 = new PrjPlanDetailEntity();
p1.setPlanStartDate(new Date());
p1.setPlanEndDate(DateUtils.parse("2020-12-16", "yyyy-MM-dd"));
PrjBdgDetailEntity p2 = new PrjBdgDetailEntity();
BeanUtils.copyProperties(p2, p1);
System.out.println(p2.getPlanEndDate());
p2對象的planEndDate字段打印出來數據說明拷貝成功了
