springframework.beans.BeanUtils.copyProperties()方法注意事项
copyProperties方法中,若source 和 target 的属性复制是通过属性名进行复制,但是如果属性名相同但属性类型不一致,也无法成功复制;
public static void copyProperties(Object source, Object target) throws BeansException { copyProperties(source, target, (Class)null, (String[])null); }
示例
Account类
%E6%96%B9%E6%B3%95%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%2FAccountVO%E7%B1%BB.png)
AccountVO类
%E6%96%B9%E6%B3%95%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%2FAccount%E7%B1%BB.png)
测试
%E6%96%B9%E6%B3%95%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%2F%E6%B5%8B%E8%AF%95%E7%BB%93%E6%9E%9C.png)