2. PropertyUtils
3. ConvertUtils
import org.apache.commons.beanutils.BeanUtils;
public class BeanUtilsExample {
public static void main(String[] args) throws Exception {
SourceBean source = new SourceBean();
source.setAge(20);
DestinationBean destination = new DestinationBean();
BeanUtils.copyProperties(destination, source);
}
}
class SourceBean {
private String name;
private int age;
}
class DestinationBean {
private String name;
private int age;
}
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>