问题描述:
Error attempting to get column 'modify_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException: getObject with type
; getObject with type; nested exception is java.sql.SQLFeatureNotSupportedException: getObject with type, stackTraceorg.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'modify_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException: getObject with type
问题分析:
1、mybatis-plus和shardingsphere集成,数据库datetime类型转java的LocalDateTime类型时调用org.apache.ibatis.type.LocalDateTimeTypeHandler.getNullableResult方法,会导致找不到LocalDateTime类型的ResultSet.getObject()方法。
解决办法:
(1)增加mybatis-typehandlers-jsr310依赖,该依赖重写了LocalDateTimeTypeHandler类,不过要加在mybatis-plus-boot-starter依赖之前。
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
(2)自己重写LocalDateTimeTypeHandler类,具体步骤请参考以下博客。