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 许可协议。转载请注明出处!
    声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
  • 相关阅读:
    《天才在左,疯子在右》
    MVC思想概述
    java文件读写
    HTTP协议简单笔记
    自学Python_Day01
    Linux基础介绍篇
    PHP学习 Day_01
    Linux中部分命令英语全拼
    Linux学习基础命令(三)
    Linux学习基础命令(二)
  • 原文地址:https://www.cnblogs.com/cheng2839/p/13180524.html
Copyright © 2011-2022 走看看