使用Spring提供的BeanUtils.copyProperties()方法报错:Could not copy property 'xxx' from source to target
使用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的属性类型使用包装类型,不要使用基本类型。
使用Spring提供的BeanUtils.copyProperties()方法报错:Could not copy property 'xxx' from source to target的更多相关文章
- Spring Data JPA使用getOne方法报错:Method threw 'org.hibernate.LazyInitializationException' exception. Cannot evaluate
getOne是懒加载,需要增加这个配置: spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true,但这种方式不太友好,建议不要使用 ...
- 项目实体类使用@Data注解,但是项目业务类中使用getA(),setA()方法报错,eclipse中配置lombok
@Data注解来源与Lombok,可以减少代码中大量的set get方法,大量减少冗余代码,但是今天部署项目时候,发现实体类使用@Data注解,但是项目业务类中使用getA(),setA()方法报错. ...
- eclipse中运行 main 方法报错,找不到类
eclipse (maven 项目)中运行 main 方法报错,找不到类 ** 发现:在 eclipse中的 "Marker" 控制面板中 ,发现问题所在 只要删除 maven 仓 ...
- Android webview js 调用java方法报错"Uncaught TypeError: Object [object Object] has no method xx
webview开发,在Android4.4下js调用java方法报错"Uncaught TypeError: Object [object Object] has no method,同样的 ...
- appium+python自动化64-使用Uiautomator2执行driver.keyevent()方法报错解决
前言 未加'automationName': 'Uiautomator2'参数使用Uiautomator可以正常使用driver.keyevent()方法,使用Uiautomator2时driver. ...
- BeanUtils.copyProperties()方法和PropertyUtils.copyProperties()的区别
首先两者来源于同一个包: import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.Prop ...
- SpringBoot关于SpringDataJpa中findOne()方法报错问题
问题描述: 首先用的SpringDataJPA的1.11版本,可以使用findOne()方法根据id查询 然后我使用了2.0.5版本,发现findOne()方法报错了,不能用来当作根据id查询了. 当 ...
- moviepy AudioClip的max_volume方法报错ValueError: operands could not be broadcast together with shapes(2,)
☞ ░ 前往老猿Python博文目录 ░ 在<moviepy音视频剪辑:AudioClip的max_volume方法报TypeError: bad operand type for abs(): ...
- spring测试save方法报错
用test类测试service的save方法时,报错如下: 2018-08-24 21:52:13,506 - could not read a hi value com.mysql.jdbc.exc ...
- 桥接:JS调用安卓方法报错Uncaught Error: Error calling method on NPObject
说一说自己粗心踩到的一个不算坑的坑: 项目是安卓webview嵌入SPA单页应用页面,涉及到JS调用原生安卓方法,但就是在调用安卓方法时死活一直报错xxx NPObject一堆错误.写了一个测试页面 ...
随机推荐
- FirewallD is not running 原因与解决方法
解决方法关于linux系统防火墙: centos5.centos6.redhat6系统自带的是iptables防火墙.centos7.redhat7自带firewall防火墙.ubuntu系统使用的是 ...
- 9. JS的数据类型,区别
js 有2大数据类型分类 : 基本数据类型: 1. string 字符串 使用单.双引号包裹,或者使用反引号包裹 2. number 数字类型 3. boolean 布尔值 true false 4. ...
- 谈一谈你对vue指令的理解
vue指令的本质是给 html 标签新增一些属性 : vue的指令可以分为 3 中类型 : 1. 用于渲染数据的指令,比如 v-for ,v-if ,v-show : 2. 用来交互的指令 ,v-on ...
- 在 Exchange Server 中配置特定于客户端的消息大小限制
在 Exchange Server 中配置特定于客户端的消息大小限制 微软官方详细文档如下: https://learn.microsoft.com/zh-cn/exchange/architectu ...
- 蜘点云原生之 KubeSphere 落地实践过程
作者:池晓东,蜘点商业网络服务有限公司技术总监,从事软件开发设计 10 多年,喜欢研究各类新技术,分享技术. 来源:本文由 11 月 25 日广州站 meetup 中讲师池晓东整理,整理于该活动中池老 ...
- JavaScript网页设计案例
1.引言 在前端开发中,JavaScript 无疑是一个非常重要的语言.它不仅可以用于表单验证.动态内容更新,还能实现复杂的交互效果和动画.通过 JavaScript,网页变得更加生动和富有互动性.本 ...
- 项目运行时,tomcat服务器端口被占用
1.查看tomcat配置文件: 2.查看项目控制台的打印信息: 3.dos命令行解决端口占用 (1)dos命令模式下输入: netstat -ano (进入dos命令:Win + R ,输入cmd ) ...
- C#线性查找算法
前言 线性查找算法是一种简单的查找算法,用于在一个数组或列表中查找一个特定的元素.它从数组的第一个元素开始,逐个检查每个元素,直到找到所需的元素或搜索完整个数组.线性查找的时间复杂度为O(n),其中n ...
- Java新特性-四大函数式接口
四大函数式接口指的是Consumer.Function.Predicate.Supplier,位于java.util.function包下: 函数式编程 lamabda表达式 函数式接口:在java中 ...
- 用JavaScriptt从一个路径字符串中获取文件名
思路 1.通过'\'关键字用split分割成数组 2.取分割后数组的最后一个就是文件名 3.另外,字符串中\是没意义的,需要2个\\ 相关代码 <script> var a='C:\\Pr ...