關於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