Sha*_*thi 5 java apache-commons-beanutils spring-bean
我有实体课
public Class StudentEntity{
private int id;
private String name;
private AddressEntity address;
private ProfileEntity profile;
//getter setter
}
public Class StudentDTO{
private int id;
private String name;
private AddressDTO address;
private ProfileDTO profile;
//getter setter
}
Run Code Online (Sandbox Code Playgroud)
当我使用BeanUtils.copyProperties();(从spring/apache常见)它复制id并且name单独使用.如何复制address和profile也?
如果必须编写custom util,请分享一下代码段吗?
您可以尝试使用 SerializationUtils.clone()。此方法深度克隆您的对象。但您应该将对象标记为可序列化。
| 归档时间: |
|
| 查看次数: |
711 次 |
| 最近记录: |