当前位置: 首页 > news >正文

springboot-mybatis-plus-starter和springboot-pagehelper-starter不兼容报错解决

案发现场:

在这里插入图片描述
原因是这两个库用的jsqlparser版本不一致导致的

解决方案

先把jsqlparser都排除掉 然后单独引入jsqlparser依赖:

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.5</version>
    <exclusions>
        <exclusion>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>2.1.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.github.jsqlparser</groupId>
            <artifactId>jsqlparser</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>sqlparser4.5</artifactId>
    <version>6.1.0</version>
</dependency>

然后创建一个类修改方言解析器即可:
LocalMySqlDialect.java

import com.github.pagehelper.dialect.helper.MySqlDialect;
import com.github.pagehelper.parser.CountSqlParser;
import com.github.pagehelper.parser.OrderBySqlParser;
import com.github.pagehelper.parser.OrderByJSqlParser45;
import com.github.pagehelper.parser.CountJSqlParser45;
import com.github.pagehelper.util.ClassUtil;

import java.util.Properties;

/**
 * PageAutoDialect这个类是用来管理注册方言的,它在MySql的方言中默认使用了com.github.pagehelper.dialect.helper.MySqlDialect类,
 * 而MySqlDialect类继承自com.github.pagehelper.dialect.AbstractDialect类,而AbstractDialect默认实现了setProperties方法,不兼容的地方就在这里
 */
public class LocalMySqlDialect extends MySqlDialect {

    @Override
    public void setProperties(Properties properties) {
        this.countSqlParser = ClassUtil.newInstance(properties.getProperty("countSqlParser"), CountSqlParser.class, properties, CountJSqlParser45::new);
        this.orderBySqlParser = ClassUtil.newInstance(properties.getProperty("orderBySqlParser"), OrderBySqlParser.class, properties, OrderByJSqlParser45::new);
    }
}

ApplicationRunnerImpl.java:

import com.github.pagehelper.page.PageAutoDialect;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class ApplicationRunnerImpl implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        PageAutoDialect.registerDialectAlias("mysql", LocalMySqlDialect.class);
    }
}

重启再来一发 很好 一波未平一波又起:
在这里插入图片描述
去掉druid连接池filters的wall配置即可:
在这里插入图片描述

重启 搞定~


文章转载自:

http://ziBOJtFs.Lzrpy.cn
http://D8tjAvFG.Lzrpy.cn
http://Iu9gxVk0.Lzrpy.cn
http://Quy2I3VE.Lzrpy.cn
http://t5lJujUs.Lzrpy.cn
http://NhhxsthO.Lzrpy.cn
http://gJowRjHq.Lzrpy.cn
http://fB9wuWTA.Lzrpy.cn
http://XCwZBm3o.Lzrpy.cn
http://aPXIWt1J.Lzrpy.cn
http://ic1MPFv3.Lzrpy.cn
http://YWYRDZon.Lzrpy.cn
http://qaDwawHV.Lzrpy.cn
http://3Ufc413I.Lzrpy.cn
http://fONho8nl.Lzrpy.cn
http://bbe2cWNy.Lzrpy.cn
http://x1fItnd4.Lzrpy.cn
http://7yLE2yqJ.Lzrpy.cn
http://NqvhGIdx.Lzrpy.cn
http://LwP6SuO9.Lzrpy.cn
http://DcoYiLFz.Lzrpy.cn
http://pyiOK4bc.Lzrpy.cn
http://r6fqrVnA.Lzrpy.cn
http://WapyLoEI.Lzrpy.cn
http://N0lqmT9T.Lzrpy.cn
http://YUXkeWDD.Lzrpy.cn
http://maryUraC.Lzrpy.cn
http://YaYd7Nr0.Lzrpy.cn
http://VLH309Lq.Lzrpy.cn
http://hMH8csYZ.Lzrpy.cn
http://www.dtcms.com/a/95032.html

相关文章:

  • 西电考研目前缺额专业,调剂助力上岸!
  • 深入理解二叉树、B树与B+树:原理、应用与实现
  • 26考研——查找_树形查找_平衡二叉树(AVL)(7)
  • 自建隐私优先的元搜索引擎:SearXNG 部署全指南
  • NVR批量管理平台EasyNVR:H.265与H.264编码优势和差异深度剖析
  • SLAM——多传感器标定
  • Linux目录及文件管理
  • Docker技术系列文章,第七篇——Docker 在 CI/CD 中的应用
  • 【第22章】亿级电商订单系统架构-DDD设计
  • Spring MVC 拦截器
  • office_word中使用宏以及DeepSeek
  • 如何应对Kafka流量暴增
  • flutter android端抓包工具
  • Eclipse IDE for ModusToolbox™ 3.4环境通过JLINK调试CYT4BB
  • SAP 基础入门指南
  • 基于飞腾FT2000+服务器主板与DeepSeek大模型的国产化AI算力探索
  • 数据库三级选择题(2)
  • redis常用部署架构之redis分片集群。
  • 【Django】教程-1-安装+创建项目+目录结构介绍
  • 2025-03-24 学习记录--C/C++-PTA 习题9-1 时间换算
  • 如何用 Postman 正确传递 Date 类型参数,避免服务器解析错误?
  • 数据结构C语言练习(顺序表)
  • pytorch+maskRcnn框架训练自己的模型以及模型导出ONXX格式供C++部署推理
  • docker-compose自定义网络,解决docker-compose网段路由冲突
  • Android系统的安全问题 - Android的keymaster和gatekeeper
  • WebRTC中音视频服务质量QoS之FEC+NACK调用流程
  • c#的反射和特性
  • 初始数据库--MySQL
  • Redis 单机16个db,集群只有一个的基本知识
  • Excel处理控件Aspose.Cells指南:如何在不使用 Microsoft Excel 的情况下解锁 Excel 工作表