使用Spring提供的BeanUtils.copyProperties()方法报错:Could not copy property 'xxx' from source to target
2017-07-09 20:10
2396 查看
使用Spring提供的BeanUtils.copyProperties()方法报错:Could not copy property 'xxx' from source to target; nested exception is java.lang.IllegalArgumentException 调用的方法:org.springframework.beans.BeanUtils.copyProperties(Object source, Object target) 报错: org.springframework.beans.FatalBeanException: Could not copy property 'adgroupId' from source to target; nested exception is java.lang.IllegalArgumentException at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:615) at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:528) ... 分析: 在使用Spring提供的BeanUtils.copyProperties(Object source, Object target)方法时,如果target中的属性含有基本类型,而source中对应的属性值为null, 则copy时,就相当于给一个基本类型赋值null,故报错。 解决方法: javaBean的属性类型使用包装类型,不要使用基本类型。
相关文章推荐
- Could not copy property 'id' from source to target异常
- Could not copy properties from source to target异常解决
- 重写org.springframework.beans.BeanUtils的copyProperties(Object source,Object target)方法 从model复制属性到pojo中
- Spring boot bootstrap.yml文件使用遇见的坑Failed to load property source from location 'classpath:/bootstrap.
- java 使用BeanUtils.copyProperties(Object source,Object target) 复制字段值
- 警告:[SetPropertiesRule]Setting property 'source' to xxx did not find a matching property.的消除
- error MSB3027: Could not copy "xxx.dll" to "xxx.dll". Exceeded retry count of 10. Failed.
- PropertyUtils.copyProperties和BeanUtils.copyProperties使用区别
- BeanUtils.copyProperties(source, target)用法
- OSG could not find plugin to read objects from file xxx.xxx
- BeanUtils.copyProperties(source, target)用法
- BeanUtils.copyProperties()方法和PropertyUtils.copyProperties()的区别
- BeanUtils.copyProperties()方法和PropertyUtils.copyProperties()的区别
- 关于使用Java Mail进行邮件发送,抛出Could not connect to SMTP host: xx@xxx.com, port: 25的异常可能
- Spring中BeanUtils.copyProperties方法测试
- 关于BeanUtils.copyProperties( )方法的使用
- PropertyPlaceholderConfigurer的用法(使用spring提供的类读取数据库配置信息.properties)
- Spring中BeanUtils.copyProperties方法测试
- BeanUtils.copyProperties()方法和PropertyUtils.copyProperties()的区别 [转]
- Visual Studio 2010 发布Web项目提示The target "PipelinePreDeployCopyAllFilesToOneFolder" does not exist in the project.解决方法