org.springframework.beans.FatalBeanException: Could not copy property 'commentCounts' from source to target; nested exception is java.lang.IllegalArgumentException
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:800)
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:701)
at com.dxh.blog.service.impl.ArticleServiceImpl.copy(ArticleServiceImpl.java:75)
at com.dxh.blog.service.impl.ArticleServiceImpl.copyList(ArticleServiceImpl.java:53)
at com.dxh.blog.service.impl.ArticleServiceImpl.hotArticle(ArticleServiceImpl.java:133)
at com.dxh.blog.dao.controller.ArticleController.hotArticle(ArticleController.java:34)
Could not copy property ‘commentCounts’ from source to target; nested exception is java.lang.IllegalArgumentException
原因:两个bean中 共同存在的属性的数据类型不匹配
可以想象到的是,如果源对象中某个属性值是空的话,那么value值也将为null,传给目标对象的对应属性的值也就是null。
所以,如果恰好该属性是基本类型的话,给一个基本类型赋值null,肯定会抛异常了!
版权声明:本文为weixin_46044901原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。