报错情况:

 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()返回的情况:

 

 

 

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐