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

MyBatis-plus使用lambda條件構(gòu)造器報(bào)錯(cuò)問題及解決

 更新時(shí)間:2024年01月31日 10:26:59   作者:weixin_42137296  
這篇文章主要介紹了MyBatis-plus使用lambda條件構(gòu)造器報(bào)錯(cuò)問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

使用lambda條件構(gòu)造器報(bào)錯(cuò)

最近在學(xué)習(xí)mybatis-plus的使用,提高工作效率;在學(xué)習(xí)到使用lambda條件構(gòu)造器查詢時(shí)報(bào)錯(cuò)

我寫的測試類如下:

    @Test
    void selectLambda() {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(User :: getName, "W")
                .and(o -> o.lt(User :: getAge, 35));
        List<User> users = userMapper.selectList(queryWrapper);
        System.out.println(users);
    }

測試方法運(yùn)行,

提示如下錯(cuò)誤

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'. Cause: org.apache.ibatis.ognl.OgnlException: sqlSegment [java.lang.ExceptionInInitializerError]
 
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
    at jdk.proxy2/jdk.proxy2.$Proxy68.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166)
    at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
    at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
    at jdk.proxy2/jdk.proxy2.$Proxy74.selectList(Unknown Source)
    at com.mingyuanmao.mpdemo.MpdemoApplicationTests.selectLambda(MpdemoApplicationTests.java:90)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere'. Cause: org.apache.ibatis.ognl.OgnlException: sqlSegment [java.lang.ExceptionInInitializerError]
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:55)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:35)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.lambda$apply$0(MixedSqlNode.java:32)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:39)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:305)
    at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:69)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
    at jdk.proxy2/jdk.proxy2.$Proxy87.query(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
    ... 73 more
Caused by: org.apache.ibatis.ognl.OgnlException: sqlSegment [java.lang.ExceptionInInitializerError]
    at org.apache.ibatis.ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:2165)
    at org.apache.ibatis.ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:66)
    at org.apache.ibatis.ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:160)
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:3373)
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:121)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.ASTChain.getValueBody(ASTChain.java:141)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:50)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:586)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:550)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:46)
    ... 99 more

看到這種錯(cuò)誤我一臉懵逼

代碼都是照著官網(wǎng)和推薦的學(xué)習(xí)視頻敲得,lambda的語法用的也是最簡單的,應(yīng)該沒有語法錯(cuò)誤,但就是無法執(zhí)行成功;

我使用的mybatis-plus的版本號(hào)為:3.4.3.2,是現(xiàn)在最新的版本

項(xiàng)目依賴如下:

在網(wǎng)上找了好久的解決方案,基本上都是讓我把mybatis-plus的版本回退到3.1.0,我也試了一下,確實(shí)可以,但是我覺得3.1.0的版本還是太舊了,于是繼續(xù)baidu,希望能繼續(xù)找到解決方案。

最后我在mybatis-plus的更新日志里發(fā)現(xiàn)一條:

更新日志里說3.4.4.2的版本解決了lambda在JDK16中無法運(yùn)行的問題,而我因?yàn)槭亲詫W(xué)項(xiàng)目,正好JDK用的就是JDK16,于是我試著把項(xiàng)目的JDK改為1.8,然后試著運(yùn)行一下,居然可以了 o(╥﹏╥)o,WC浪費(fèi)了我好多時(shí)間。。。。。

執(zhí)行成功截圖:

實(shí)在是太坑了

因此記錄一下;看來官方的更新文檔與事實(shí)不符啊o(╥﹏╥)o

不過現(xiàn)在企業(yè)項(xiàng)目中應(yīng)該還沒有用到JDK16的,基本上都是1.8或者11

所以大家還是可以放心在項(xiàng)目中加上新版的mybatis-plus使用

用起來還是蠻香的,O(∩_∩)O哈哈~

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Springboot詳解實(shí)現(xiàn)食品倉庫管理系統(tǒng)流程

    Springboot詳解實(shí)現(xiàn)食品倉庫管理系統(tǒng)流程

    這是一個(gè)使用Springboot開發(fā)的食品倉庫管理系統(tǒng),是為商家提供商品貨物進(jìn)銷存的信息化管理系統(tǒng),具有一個(gè)倉庫管理系統(tǒng)該有的所有功能,感興趣的朋友快來看看吧
    2022-06-06
  • Java語言class類用法及泛化(詳解)

    Java語言class類用法及泛化(詳解)

    這篇文章主要介紹了Java語言class類用法及泛化(詳解),大家都知道Java程序在運(yùn)行過程中,對(duì)所有的對(duì)象今夕類型標(biāo)識(shí),也就是RTTI。這項(xiàng)信息記錄了每個(gè)對(duì)象所屬的類,需要的朋友可以參考下
    2015-07-07
  • Java Web實(shí)現(xiàn)session過期后自動(dòng)跳轉(zhuǎn)到登陸頁功能【基于過濾器】

    Java Web實(shí)現(xiàn)session過期后自動(dòng)跳轉(zhuǎn)到登陸頁功能【基于過濾器】

    這篇文章主要介紹了Java Web實(shí)現(xiàn)session過期后自動(dòng)跳轉(zhuǎn)到登陸頁功能,涉及java過濾器針對(duì)session的判斷與跳轉(zhuǎn)相關(guān)操作技巧,需要的朋友可以參考下
    2017-11-11
  • Springboot的Mapper中添加新的SQL語句方法詳解

    Springboot的Mapper中添加新的SQL語句方法詳解

    在如今的軟件開發(fā)界,Spring Boot可是非常受歡迎的框架哦,尤其是在微服務(wù)和RESTful API的構(gòu)建上,下面給大家介紹我們?nèi)绾螢镾pring Boot項(xiàng)目中的Mapper添加新的SQL語句吧,感興趣的朋友一起看看吧
    2025-04-04
  • Java中IO和NIO的區(qū)別詳細(xì)解析

    Java中IO和NIO的區(qū)別詳細(xì)解析

    這篇文章主要介紹了Java中IO和NIO的區(qū)別詳細(xì)解析,IO和NIO有相同的作用和目的,但實(shí)現(xiàn)方式不同,NIO主要用到的是塊,所以NIO的效率要比IO快不少,需要的朋友可以參考下
    2023-11-11
  • 使用JSCH框架通過跳轉(zhuǎn)機(jī)訪問其他節(jié)點(diǎn)的方法

    使用JSCH框架通過跳轉(zhuǎn)機(jī)訪問其他節(jié)點(diǎn)的方法

    下面小編就為大家分享一篇使用JSCH框架通過跳轉(zhuǎn)機(jī)訪問其他節(jié)點(diǎn)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2017-12-12
  • javaWeb項(xiàng)目部署到阿里云服務(wù)器步驟詳解

    javaWeb項(xiàng)目部署到阿里云服務(wù)器步驟詳解

    本篇文章主要介紹了javaWeb項(xiàng)目部署到阿里云服務(wù)器步驟詳解,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2017-05-05
  • Java中JVM的類加載器詳解

    Java中JVM的類加載器詳解

    這篇文章主要介紹了Java中的類加載器詳解,從概念上來講, 自定義類加載器一般指的是程序中由開發(fā)人員自定義的類加載器,但是Java虛擬機(jī)規(guī)范卻沒有這么定義,而是將所有派生于抽象類ClassLoader的類加載器都劃分為自定義類加載器,需要的朋友可以參考下
    2023-07-07
  • 零基礎(chǔ)寫Java知乎爬蟲之獲取知乎編輯推薦內(nèi)容

    零基礎(chǔ)寫Java知乎爬蟲之獲取知乎編輯推薦內(nèi)容

    上篇文章我們拿百度首頁做了個(gè)小測試,今天我們來個(gè)復(fù)雜的,直接抓取知乎編輯推薦的內(nèi)容,小伙伴們可算松了口氣,終于進(jìn)入正題了,哈哈。
    2014-11-11
  • Java中基于物理屬性和內(nèi)容校驗(yàn)比較兩個(gè)文件是否一致

    Java中基于物理屬性和內(nèi)容校驗(yàn)比較兩個(gè)文件是否一致

    這篇文章主要介紹了Java中基于物理屬性和內(nèi)容校驗(yàn)比較兩個(gè)文件是否一致,當(dāng)一個(gè)文件經(jīng)過哈希函數(shù)處理后,會(huì)得到一個(gè)唯一代表其內(nèi)容的哈希值,如果這個(gè)文件被篡改,哈希值也會(huì)發(fā)生改變,通過比較文件的哈希值,可以輕松地驗(yàn)證文件的完整性和一致性,需要的朋友可以參考下
    2025-10-10

最新評(píng)論

吴桥县| 牡丹江市| 酒泉市| 大埔区| 封开县| 绥棱县| 祁阳县| 山阴县| 海安县| 宁乡县| 河北区| 青神县| 方山县| 湘阴县| 桃江县| 渭南市| 阿鲁科尔沁旗| 苍梧县| 江山市| 瑞安市| 阿城市| 固原市| 冕宁县| 晋城| 沧州市| 雷州市| 监利县| 准格尔旗| 衡南县| 扎鲁特旗| 宣城市| 盐山县| 抚州市| 法库县| 南靖县| 武隆县| 两当县| 荃湾区| 古浪县| 泊头市| 葵青区|