报错情况:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'createTime' of 'class com.itheima.reggie.entity.Employee' with value 'Fri Sep 02 10:40:50 CST 2022' Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause
具体看这段报错:
Could not set property 'createTime' of 'class com.itheima.reggie.entity.Employee' with value 'Fri Sep 02 10:40:50 CST 2022'
翻译:无法设置类com.itheima.reggie.entity的属性“createTime”。中国夏令时2022年9月2日星期五10:40:50
报错场景:
在MySQL存入的时间:
在Java用LocalDateTime.now()向Mysql传入的是
Fri Sep 02 10:40:50 CST 2022
问题解析:
暂时确定是不是格式问题。
解决方案:
将传入的LocalDateTime.now()改为new Date()就可以解决。并且将实体类的返回也改成Date就行了
new Date()返回的情况:
LocalDateTime()返回的情况: