问题:数据库中变量类型为datetime,实体类中变量类型为localdatetime,在进行查询数据库操作时,查询结果不能进行自动映射,报错信息如下:

Error attempting to get column ‘create_time’ from result set.  Cause: java.sql.SQLException: Error

解决方法

1.添加注解

@JsonFormat(shape= sonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")

例:

 2.添加依赖:pom文件

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-typehandlers-jsr310</artifactId>
    <version>1.0.1</version>
</dependency>

参考解决方案:https://blog.csdn.net/sinat_26671533/article/details/103043755


另外一个方法,还没试过

注意:
LocalDateTimeDeserializer.classLocalDateTimeSerializer.class必须添加依赖后才会引用,否则无法使用。
Web项目中没有pom.xml文件,所以依赖是添加在build.gradle里的。

参考:​https://blog.csdn.net/Bejpse/article/details/123422254​


版权声明:本文为weixin_47314924原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_47314924/article/details/128606227