pagehelper与mybatis-plus冲突的解决办法

背景:

springcloud项目开发新功能时因想使用mybatis-plus,原有功能只使用了mybatis,但在开发时发现某个公共模块使用了com.github.pagehelper,且很多模块都集成了该模块依赖(为了保证原有功能不发生问题,因此pagehelper依赖不能动),若想使用mybatis-plus就会与pagehelper依赖冲突(新功能也是需要依赖之前的公共模块)

以下是新开发功能模块的完整依赖:

XML 复制代码
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    <!-- mybatis plus  -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.5.2</version>
    </dependency>
    <!--多数据源依赖-->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
        <version>3.5.2</version>
    </dependency>
    <!--当前系统公共模块-->
    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>当前系统的公共模块</artifactId>
        <version>1.0</version>
        <exclusions>  <!--公共模块需要排除以下2个依赖,与mybatis-plus冲突  -->
            <exclusion>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper-spring-boot-starter</artifactId>
            </exclusion>
            <exclusion>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <!--连接池-->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>druid</artifactId>
        <version>1.1.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
</dependencies>

解决冲突的办法就是虽然依赖公共模块,只需要排除掉与mybatis-plus有冲突的jar包即可

相关推荐
hssfscv1 小时前
Javaweb学习笔记——JDBC和Mybatis
笔记·学习·mybatis
cike_y1 小时前
Spring整合Mybatis:dao层
java·开发语言·数据库·spring·mybatis
雨中飘荡的记忆2 小时前
MyBatis设计模式之构建者、工厂、代理模式
mybatis
while(1){yan}11 小时前
Mybatis基础(详解)
spring boot·spring·java-ee·mybatis
多多*14 小时前
2026年1月3日八股记录
java·开发语言·windows·tcp/ip·mybatis
草原印象17 小时前
Spring、SpringMVC、Mybatis框架整合实战视频课程
java·spring·mybatis
雨中飘荡的记忆19 小时前
MyBatis映射器模块详解
mybatis
计算机学姐21 小时前
基于SpringBoot的个人健康管理系统【2026最新】
java·spring boot·后端·mysql·spring·intellij-idea·mybatis
雨中飘荡的记忆1 天前
MyBatis会话模块详解
mybatis
气π1 天前
【JavaWeb】——帝可得实践项目-App与设备端补充
java·spring boot·mybatis