mybatis-plus 中使用LocalDateTime报错:Error attempting to get column 'create_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException
问题描述:
mybatis-plus 3.3.2 ,druid连接池:1.1.10 ,数据库中的时间类型是: datetime ,实体中是Localdatetime 类型的, 导致查询直接会报上面截图的问题
最后发现是集成 druid的问题,集成druid数据源,使用3.1.0之前版本没问题,升级mp到3.1.1+后,运行时报错:java.sql.SQLFeatureNotSupportedException
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
问题原因: mybaits-plus 3.1.1+使用了新版jdbc,LocalDateTime等新日期类型处理方式升级,但druid在1.1.21版本之前不支持
解决方案:
1. 升级druid到1.1.21解决这个问题;
2.保持mp版本3.1.0;
3.紧跟mp版本,换掉druid数据源(我采用的:果断换掉druid,实用boot默认的)