最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

解決mybatis-plus使用jdk8的LocalDateTime 查詢時(shí)報(bào)錯(cuò)的方法

 更新時(shí)間:2020年08月24日 10:46:21   作者:Kalvin_csdn  
這篇文章主要介紹了解決mybatis-plus使用jdk8的LocalDateTime 查詢時(shí)報(bào)錯(cuò)的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

mybatis-plus使用jdk8的LocalDateTime

查詢時(shí)報(bào)錯(cuò):

org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'update_time' from result set.  Cause: java.sql.SQLFeatureNotSupportedException
; null; nested exception is java.sql.SQLFeatureNotSupportedException

廢話少說,直接上例子代碼:

實(shí)體類:

以下實(shí)體類創(chuàng)建時(shí)間字段使用了LocalDateTime 

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_user")
public class User extends BaseEntity {

  private static final long serialVersionUID = 1L;

  /**
   * 主鍵
   */
  @TableId(value = "id", type = IdType.AUTO)
  private Long id;

  /**
   * 歸屬部門
   */
  private Long deptId;

  /**
   * 登錄名
   */
  private String username;

  /**
   * 密碼
   */
  private String password;

  /**
   * 姓名
   */
  private String realname;

  /**
   * 性別。0:未知;1:男;2:女
   */
  private Integer sex;

  /**
   * 手機(jī)號(hào)碼
   */
  private String phone;

  /**
   * 創(chuàng)建時(shí)間
   */
  private LocalDateTime createTime;

}

單元測(cè)試:

 @Test
  public void contextLoads() {

    User admin = userService.getByUsername("admin");
    LOGGER.info("admin={}", admin);
  }

單元測(cè)試報(bào)錯(cuò):

org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'update_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException
; null; nested exception is java.sql.SQLFeatureNotSupportedException

 at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:96)
 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
 at com.sun.proxy.$Proxy75.selectOne(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
 at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:99)
 at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:61)
 at com.sun.proxy.$Proxy76.selectOne(Unknown Source)
 at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.getOne(ServiceImpl.java:255)
 at com.baomidou.mybatisplus.extension.service.IService.getOne(IService.java:192)
 at com.kalvin.layoa.service.oa.UserServiceImpl.getByUsername(UserServiceImpl.java:42)
 at com.kalvin.layoa.LayOaApplicationTests.contextLoads(LayOaApplicationTests.java:16)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
 at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
 at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
 at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
 at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
 at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
 at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
 at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
 at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
 at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
 at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
 at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.sql.SQLFeatureNotSupportedException
 at com.alibaba.druid.pool.DruidPooledResultSet.getObject(DruidPooledResultSet.java:1771)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:69)
 at com.sun.proxy.$Proxy114.getObject(Unknown Source)
 at org.apache.ibatis.type.LocalDateTimeTypeHandler.getNullableResult(LocalDateTimeTypeHandler.java:38)
 at org.apache.ibatis.type.LocalDateTimeTypeHandler.getNullableResult(LocalDateTimeTypeHandler.java:28)
 at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:81)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyAutomaticMappings(DefaultResultSetHandler.java:521)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:402)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:354)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:328)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:301)
 at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:194)
 at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65)
 at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
 at com.sun.proxy.$Proxy111.query(Unknown Source)
 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
 ... 39 more

解決方法:

  • mybatis-plus版本降至3.1.0或以下即可
  • 也可以參考下面網(wǎng)友提供的其它解決方法
  • 官方解決方案: 1. 升級(jí)druid到1.1.21解決這個(gè)問題;2.保持mp版本3.1.0;3.緊跟mp版本,換掉druid數(shù)據(jù)源

到此這篇關(guān)于解決mybatis-plus使用jdk8的LocalDateTime 查詢時(shí)報(bào)錯(cuò)的方法的文章就介紹到這了,更多相關(guān)mybatis-plus LocalDateTime 查詢內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

  • Java實(shí)現(xiàn)“年-月-日 上午/下午時(shí):分:秒”的簡單代碼

    Java實(shí)現(xiàn)“年-月-日 上午/下午時(shí):分:秒”的簡單代碼

    當(dāng)前的日期輸出的方法有很多,本文為大家介紹下在java中是如何實(shí)現(xiàn)“年-月-日 上午/下午時(shí):分:秒”,感興趣的朋友不妨參考下
    2015-08-08
  • java?Web實(shí)現(xiàn)用戶登錄功能圖文教程

    java?Web實(shí)現(xiàn)用戶登錄功能圖文教程

    這篇文章主要給大家介紹了關(guān)于java?Web實(shí)現(xiàn)用戶登錄功能的相關(guān)資料,在開發(fā)Web應(yīng)用程序中,用戶登錄是一個(gè)常見的功能,文中通過代碼以及圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-10-10
  • Java通過正則表達(dá)式獲取域名簡單示例

    Java通過正則表達(dá)式獲取域名簡單示例

    在Java中可以使用正則表達(dá)式來從字符串中匹配和提取域名,下面這篇文章主要給大家介紹了關(guān)于Java通過正則表達(dá)式獲取域名的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • 淺談resultMap的用法及關(guān)聯(lián)結(jié)果集映射

    淺談resultMap的用法及關(guān)聯(lián)結(jié)果集映射

    這篇文章主要介紹了resultMap的用法及關(guān)聯(lián)結(jié)果集映射操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • Mybatis傳入List實(shí)現(xiàn)批量更新的示例代碼

    Mybatis傳入List實(shí)現(xiàn)批量更新的示例代碼

    這篇文章主要介紹了Mybatis傳入List實(shí)現(xiàn)批量更新的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • java同步之volatile解析

    java同步之volatile解析

    volatile可以說是Java虛擬機(jī)提供的最輕量級(jí)的同步機(jī)制了,了解volatile的語義對(duì)理解多線程的特性具有很重要的意義,下面小編帶大家一起學(xué)習(xí)一下
    2019-05-05
  • 詳解SpringBoot時(shí)間參數(shù)處理完整解決方案

    詳解SpringBoot時(shí)間參數(shù)處理完整解決方案

    這篇文章主要介紹了詳解SpringBoot時(shí)間參數(shù)處理完整解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • java隊(duì)列之queue用法實(shí)例分析

    java隊(duì)列之queue用法實(shí)例分析

    這篇文章主要介紹了java隊(duì)列之queue用法實(shí)例分析,Queue 隊(duì)列就是一個(gè)先入先出(FIFO)的數(shù)據(jù)結(jié)構(gòu),Queue接口繼承Collection接口。感興趣的可以了解一下
    2020-07-07
  • SpringBoot利用切面注解及反射實(shí)現(xiàn)事件監(jiān)聽功能

    SpringBoot利用切面注解及反射實(shí)現(xiàn)事件監(jiān)聽功能

    這篇文章主要介紹了springboot事件監(jiān)聽,通過利用切面、注解、反射實(shí)現(xiàn),接下來將對(duì)這幾種方式逐一說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助
    2022-07-07
  • Spring導(dǎo)入properties配置文件代碼示例

    Spring導(dǎo)入properties配置文件代碼示例

    這篇文章主要介紹了Spring導(dǎo)入properties配置文件代碼示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-10-10

最新評(píng)論

赤峰市| 梁平县| 抚顺县| 上杭县| 伊金霍洛旗| 荔浦县| 北辰区| 深州市| 鄢陵县| 斗六市| 庆阳市| 泰兴市| 施秉县| 城口县| 班戈县| 阿巴嘎旗| 乌拉特后旗| 高要市| 扎囊县| 南溪县| 平武县| 嘉鱼县| 武山县| 金秀| 彝良县| 霍邱县| 砀山县| 小金县| 望谟县| 贵南县| 阿图什市| 清苑县| 萨嘎县| 呼伦贝尔市| 灵石县| 德兴市| 普陀区| 泰和县| 冷水江市| 明光市| 上思县|