背景
本来使用Mybatis-Plus 3.5.1
作为持久层操作,一切正常,然后有了多数据源的使用需求,所以引入了dynamic-datasource-spring-boot-starter 3.5.1
来支持多数据源,但在引入之后发生了如下异常
Error attempting to get column 'create_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException
; null; nested exception is java.sql.SQLFeatureNotSupportedException
时间字段使用的LocalDateTime
类型
问题调查
经过Debug定位发现,在处理LocalDateTime
类型时,Mybatis-Plus会使用如下方法处理
默认实现是DruidPooledResultSet
,在DruidPooledResultSet
(旧版本druid)中的getObject(String columnLabel, Class<T> type)
方法是这样的,直接抛出这个异常,也就是暂时不支持该类型数据处理
我这是因为seata的依赖引入了druid-1.1.12.jar,所以冲突导致使用了1.1.12版本的druid
问题解决
解决druid版本冲突,提高druid依赖的版本
从druid-1.1.18
开始就支持了,所以按照需要使用1.1.18及以上版本
的druid就可以了
有其他问题欢迎留言!!!