当前位置: 首页 > 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配置即可:
在这里插入图片描述

重启 搞定~

相关文章:

  • 西电考研目前缺额专业,调剂助力上岸!
  • 深入理解二叉树、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 时间换算
  • h5响应式网站建设方案/南宁百度seo排名优化
  • 国外企业网站怎么做/新软件推广平台
  • 香河住房和建设局网站/公关负面处理公司
  • 南京营销网站开发制作报价/seo线下培训机构
  • 青岛网站开发培训价格/网站建设教程
  • 东港区网站制作/互换链接的方法