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 小时前
在Mybatis中为什么要同时指定扫描mapper接口和 mapper.xml 文件,理论单独扫描 xml 文件就可以啊
java·tomcat·mybatis
爱的叹息4 小时前
MyBatis 插件开发的完整详细例子
mybatis
Minyy1110 小时前
SpringBoot程序的创建以及特点,配置文件,LogBack记录日志,配置过滤器、拦截器、全局异常
xml·java·spring boot·后端·spring·mybatis·logback
北辰浮光17 小时前
[Mybatis-plus]
java·开发语言·mybatis
方圆想当图灵18 小时前
由 Mybatis 源码畅谈软件设计(七):SQL “染色” 拦截器实战
后端·mybatis·代码规范
毅航18 小时前
MyBatis 事务管理:一文掌握Mybatis事务管理核心逻辑
java·后端·mybatis
啊松同学1 天前
【Mybatis】MyBatisPlus的saveBatch真的是批量插入吗?深度解析与性能优化
java·后端·性能优化·mybatis
阿里小阿希1 天前
解决 Spring Boot + MyBatis 项目迁移到 PostgreSQL 后的数据类型不匹配问题
spring boot·postgresql·mybatis
凯酱1 天前
MyBatis-Plus分页插件的使用
java·tomcat·mybatis
我是福福大王1 天前
MyBatis源码学习总结
后端·mybatis