【JAVA】org.springframework.beans.FatalBeanException: Could not copy property 'beginInventory' from source to target
异常报错如下:
2020-06-23 09:52:13.674 [http-nio-8009-exec-1] [6e97d911bd4d97a5] [6e97d911bd4d97a5] [ERROR] org.springframework.beans.BeanUtils:Could not copy property 'beginInventory' from source to target; nested exception is java.lang.IllegalArgumentException org.springframework.beans.FatalBeanException: Could not copy property 'beginInventory' from source to target; nested exception is java.lang.IllegalArgumentException at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:625) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:537)
出现该异常的代码行如下:
BeanUtils.copyProperties(src, dest);
经过排查原因如下:
src的POJO类中字段定义如下:
private Integer beginInventory;
dest的POJO类中字段定义如下:
private int beginInventory;
由于src的beginInventory值为null,导致无法赋值给dest中的int类型,所以报错
解决方法是,将src中的Integer类型字段赋予一个初始值(比如0)
____________________________特此,勉励____________________________
本文作者:cheng2839
本文链接:https://www.cnblogs.com/cheng2839
关于博主:评论和私信会在第一时间回复。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/cheng2839
关于博主:评论和私信会在第一时间回复。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!

浙公网安备 33010602011771号