//BaseItem416 toAddItem = toAddMap.get(item.getKey());累加计算copy对象
BaseItem416 toAddItem = new BaseItem416();
ConvertUtils.register(new DateConverter(null), java.util.Date.class);
BeanUtils.copyProperties(toAddItem, toAddMap.get(item.getKey()));

 

直接  对象1=对象2;这种情况下改变对象2的属性,对象1也会跟着改变。用BeanUtils的copyProperties的方法复制一个全新的对象,这样就互相不影响了。

今天我的BeanUtils.copyProperties又出问题了

数据源orig有一个参数是java.util.Date类型,没有初始化值,调用BeanUtils.copyProperties方法

报错No value specified for Date,百度了下,有人说在copy之前加上


ConvertUtils.register(new DateConverter(null), java.util.Date.class);
这样代码就ok了,试了下,问题解决了,看来我对copy方法了解的还是不够深入,等下查查到底什么原理。

参考地址:

https://blog.csdn.net/ztchun/article/details/79110096

 

posted on 2020-03-27 19:45  lyjie  阅读(128)  评论(0编辑  收藏  举报