关于BeanUtils.copyProperties() 用法及区别


这两个类在不同的包下面,而这两个类的copyProperties()方法里面传递的参数赋值是相反的。

例如:
a,b为对象
BeanUtils.copyProperties(a, b);


BeanUtils是org.springframework.beans.BeanUtils, a拷贝到b

public static void copyProperties(Object source, Object target)//source 源文件,target 目标文件
        throws BeansException
    {
        copyProperties(source, target, null, (String[])null);
    }

  


BeanUtils是org.apache.commons.beanutils.BeanUtils,b拷贝到a

public static void copyProperties(Object dest, Object orig)//dest(英译:“蒸馏”,可理解为空白文件,目标文件),original原始的,源文件
        throws IllegalAccessException, InvocationTargetException
    {
        BeanUtilsBean.getInstance().copyProperties(dest, orig);
    }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM