异常报错如下:
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)