异常报错如下:

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)

 

相关文章:

  • 2021-11-26
  • 2021-04-10
  • 2021-04-17
  • 2021-11-07
  • 2021-06-17
  • 2021-09-28
  • 2021-12-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-05-18
相关资源
相似解决方案