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

相关推荐
不像程序员的程序媛4 小时前
redis的一些疑问
java·redis·mybatis
野犬寒鸦7 小时前
MyBatis-Plus 中使用 Wrapper 自定义 SQL
java·数据库·后端·sql·mybatis
代码的余温15 小时前
MyBatis集成Logback日志全攻略
java·tomcat·mybatis·logback
sniper_fandc1 天前
SpringBoot系列—MyBatis(xml使用)
java·spring boot·mybatis
Charlie__ZS1 天前
若依框架去掉Redis
java·redis·mybatis
N维世界2 天前
Mybatis-XML映射文件
xml·java·mybatis
慧一居士3 天前
MyBatis-Plus的完整使用示例,完整使用示例手册
mybatis
艺杯羹3 天前
MyBatis之核心对象与工作流程及SqlSession操作
java·mybatis
天天摸鱼的java工程师3 天前
MyBatis Plus 的实用技巧:从业务场景到代码实现
java·后端·mybatis
wuxuanok3 天前
Web后端开发-Mybatis
java·开发语言·笔记·学习·mybatis