Java 对象之间相同属性的赋值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Interesting_Talent/article/details/82461309

1.BeanUtils.copyProperties

import org.springframework.beans.BeanUtils;
User src = new User();
User dest = new User();
BeanUtils.copyProperties(dest, src);

项目应用场景:将具有相同属性的ProductVO 转为Product。(ProductVO 包含的属性比Product多,包括不在product表里的list<Tag>,List<Qa>等)

 

猜你喜欢

转载自blog.csdn.net/Interesting_Talent/article/details/82461309