【系统500错误】SqlSession was not registered for synchronization because synchronization is not active

起因:我在做瑞吉外卖项目的时候,重新开了一个项目想要复写之前的代码,但是在代码一模一样的情况下一直报500错误。

报错截图:

【系统500错误】SqlSession was not registered for synchronization because synchronization is not active_第1张图片

报错内容:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is 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]] with root cause

解决办法:

我之前的依赖如下:



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.7.10
    

    com.itheima
    reggie_take_out
    1.0-SNAPSHOT

    
        17
        17
    



    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
        

        
            org.springframework.boot
            spring-boot-starter-web
        

        
            com.baomidou
            mybatis-plus-boot-starter
            3.4.3
        

        
            org.projectlombok
            lombok
        

        
            com.alibaba
            fastjson
            1.2.76
        

        
            commons-lang
            commons-lang
            2.6
        
        
            cn.hutool
            hutool-all
            5.7.17
        

        
            mysql
            mysql-connector-java
            8.0.31
        

        
            com.alibaba
            druid-spring-boot-starter
            1.1.23
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                2.4.5
            
        
    

后面以来改为如下就运行成功了:



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.7.10
         
    
    com.itheima
    reggie_take_out
    1.0-SNAPSHOT

    
        17
        17
    
    

        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        

        
            org.springframework.boot
            spring-boot-starter-web
            compile
        

        
            com.baomidou
            mybatis-plus-boot-starter
            3.4.2
        

        
            org.projectlombok
            lombok
            1.18.20
        

        
            com.alibaba
            fastjson
            1.2.76
        

        
            commons-lang
            commons-lang
            2.6
        

        
            mysql
            mysql-connector-java
            8.0.31
            runtime
        

        
            com.alibaba
            druid-spring-boot-starter
            1.1.23
        

        
            cn.hutool
            hutool-all
            5.7.17
        

    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                2.4.5
            
        
    


经过我的一一仔细排查,发现是mybatis-plus-boot-starter版本的原因,将3.4.3下调至3.4.2即可成功运行!

你可能感兴趣的:(bug,springboot,java,bug)