<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
public class SourceBean {
private String name;
private int age;
// getters and setters
}
public class TargetBean {
private String name;
private int age;
// getters and setters
}
SourceBean sourceBean = new SourceBean();
sourceBean.setName("John");
sourceBean.setAge(25);
TargetBean targetBean = new TargetBean();
BeanUtils.copyProperties(targetBean, sourceBean);
SourceBean sourceBean = new SourceBean();
PropertyUtils propertyUtils = BeanUtils.getPropertyUtils();
PropertyDescriptor[] descriptors = propertyUtils.getPropertyDescriptors(SourceBean.class);
for (PropertyDescriptor descriptor : descriptors) {
}