SpringBoot中使用Mybatis-plus整合PageHelper分页插件踩坑

今天使用SpringBoot中使用Mybatis-plus整PageHelper分页插件把我给坑惨了,我报错的pom.xml配置如下,其它的依赖就忽略掉了

       <!--pagehelper -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.10</version>

        </dependency>
        <!--mybatis-plus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
        </dependency>

经过一短时间的排查解决,发现其主要问题还是因为pagehelper-spring-boot-starter所依赖的mybatis-spring,mybatis与 mybatis-plus-boot-starter所依赖的mybatis-spring,mybatis发生冲突只要排除掉就可以了。

下面是我能正常跑的pom.xml配置

   <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.10</version>
            <!--使用spring boot2整合 pagehelper-spring-boot-starter必须排除一下依赖
     因为pagehelper-spring-boot-starter也已经在pom依赖了mybatis与mybatis-spring
     所以会与mybatis-plus-boot-starter中的mybatis与mybatis-spring发生冲突
 -->
            <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis-spring</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--mybatis-plus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</version>
        </dependency>

 

作者:YangRoc

出处:https://www.cnblogs.com/YangRoc/p/17186616.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   Roc-xb  阅读(205)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律

易微帮源码


易微帮官网

more_horiz
keyboard_arrow_up light_mode palette
选择主题
点击右上角即可分享
微信分享提示