zoukankan      html  css  js  c++  java
  • 【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 许可协议。转载请注明出处!
    声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
  • 相关阅读:
    汤姆大叔的博客
    ajax
    兼容谷歌的光标居中写法
    浅谈服务治理与微服务
    Java线程面试题合集(含答案)
    java设计模式之装饰者模式
    java集合类详解
    java线程-看这一篇就够了
    javaIO详解
    java反射详解
  • 原文地址:https://www.cnblogs.com/cheng2839/p/13180524.html
Copyright © 2011-2022 走看看