最近在项目中,发现BeanUtils.copyProperties方法拷贝bean属性时候,有的时候会失效。最后发现是由于项目中引用了spring和common两个包,都有BeanUtils方法,错误引用导致。方法参数顺序不同,实现也不同

         org.apache.commons.beanutils.BeanUtils中的copyProperties(Object dest, Object orig),是目的bean在前,源bean在后。而org.springframework.beans.BeanUtils的copyProperties(Object source, Object target)是源在前,目的bean在后。感觉spring的实现比较精简,易懂。

posted on 2017-12-18 22:10  孤峰侠客  阅读(1078)  评论(0编辑  收藏  举报