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包即可

相关推荐
李少兄14 小时前
解决MyBatis参数绑定中参数名不一致导致的错误问题
mybatis
异常君18 小时前
MyBatis 中 SqlSessionFactory 和 SqlSession 的线程安全性深度分析
java·面试·mybatis
bing_1581 天前
跨多个微服务使用 Redis 共享数据时,如何管理数据一致性?
redis·微服务·mybatis
云之兕1 天前
MyBatis 的动态 SQL
数据库·sql·mybatis
loser.loser2 天前
QQ邮箱发送验证码(Springboot)
java·spring boot·mybatis
毅航2 天前
Trae复刻Mybatis之旅(一):创建SqlSession会话,构建代理
后端·mybatis·trae
潮流coder2 天前
mybatis的if判断==‘1‘不生效,改成‘1‘.toString()才生效的原因
java·tomcat·mybatis
BillKu2 天前
Java + Spring Boot + Mybatis 实现批量插入
java·spring boot·mybatis
dog shit2 天前
web第十次课后作业--Mybatis的增删改查
android·前端·mybatis
emo了小猫2 天前
Mybatis #{} 和 ${}区别,使用场景,LIKE模糊查询避免SQL注入
数据库·sql·mysql·mybatis