月光心事 2021-06-22 14:10 采纳率: 100%
浏览 832
已采纳

shardingshpere+mybatis项目不支持LocalDateTime

版本:

shardingsphere  4.1.0(4.4.1)+mybatis-plus 3.3.1 druid 1.1.19(至1.1.23)

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'create_time' from result set.  Cause: java.sql.SQLFeatureNotSupportedException: getObject with type
; getObject with type; nested exception is java.sql.SQLFeatureNotSupportedException: getObject with type] with root cause

java.sql.SQLFeatureNotSupportedException: getObject with type
    at org.apache.shardingsphere.shardingjdbc.jdbc.unsupported.AbstractUnsupportedOperationResultSet.getObject(AbstractUnsupportedOperationResultSet.java:221) ~[sharding-jdbc-core-4.1.1.jar:4.1.1]
    at org.apache.ibatis.type.LocalDateTimeTypeHandler.getNullableResult(LocalDateTimeTypeHandler.java:38) ~[mybatis-3.5.3.jar:3.5.3]

 

 

错误原因:

数据库字段create_time 对应实体类型 LocalDateTime(java 8)

网上好多说是由于连接池druid版本连接池导致,但我换到1.1.23还是不可以;

后来更换连接池为HikariCP,但还是不支持这个时间类型;

只有降低mybatis-plus 为3.1.0 可以;

但项目中mybatis是不允许降版本的,有解决办法的大佬不?


 
  • 写回答

2条回答 默认 最新

  • 月光心事 2021-06-28 14:18
    关注
    后来通过BaseTypeHandler解决,最好还是通过修改jar
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改