mybatis-plus使用中遇到的问题

2023-05-16

mybatis-plus使用中遇到的问题

  • mapper配置问题
  • mybatis-plus与mybatis冲突
  • mybatis-plus与pagehelper冲突

最近新搭一个测试项目,使用了 mybatis-plus当前的最新版本 3.3.1,之后遇到了一系列问题,特整理一下。

mapper配置问题

报错:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘cn.yc.sys.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate.

看报错信息,是程序未找到我的mapper,怎么会?这都是使用mybatis-plus自己的生成器生成的代码呀?
再瞄了几眼官网文档,发现如下说明:

在这里插入图片描述
汗,赶紧加上,问题解决。

mybatis-plus与mybatis冲突

报错:

Caused by: java.lang.ClassNotFoundException: org.mybatis.logging.LoggerFactory

经排查,我遇到此问题的原因,是pom中同时引用了mybatis-plus与mybatis

在这里插入图片描述
在这里插入图片描述
本人既然要使用mybatis-plus,自然是去掉mybatis的引用了,之后问题解决。

mybatis-plus与pagehelper冲突

报错:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:369)

The following method did not exist:

com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver;

The method’s class, com.baomidou.mybatisplus.core.MybatisConfiguration, is available from the following locations:

jar:file:/E:/tools_study/apache/maven/localRepository/repository/com/baomidou/mybatis-plus-core/3.3.1/mybatis-plus-core-3.3.1.jar!/com/baomidou/mybatisplus/core/MybatisConfiguration.class

It was loaded from the following location:

file:/E:/tools_study/apache/maven/localRepository/repository/com/baomidou/mybatis-plus-core/3.3.1/mybatis-plus-core-3.3.1.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.baomidou.mybatisplus.core.MybatisConfiguration

以上错误,出现的原因可能比较多:

  • mybatis-plus与spring boot版本不一致,这个版本对应可到https://mvnrepository.com/查看,打开网站,搜索mybatis-plus-boot-starter

在这里插入图片描述
不过,问题解决后经过验证,我使用mybatis-plus 3.3.1与spring boot 2.2.1,也能成功(当然,只是启动成功,也许使用中还是会有其他问题,因此版本最好还是对应起来使用)。

  • 项目中引用了多个版本的mybatis-plus
  • mybatis-plus与其他包(本人就是此原因)

经过排查,最终发现是项目中引用的pagehelper-spring-boot-starter造成的。

解决方法,两种:
一、升级pagehelper-spring-boot-starter版本,我原本使用的是1.0.0版,升级到1.2.13,问题解决。
二、在pagehelper-spring-boot-starter依赖中添加排除mybatis的选项,如下:

<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>1.0.0</version>
			<exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
            </exclusions>
		</dependency>

本人直接两种方法结合,升级版本的同时,也添加了排除选项:

<dependency>
		    <groupId>com.github.pagehelper</groupId>
		    <artifactId>pagehelper-spring-boot-starter</artifactId>
		    <version>1.2.13</version>
		    <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis</artifactId>
                </exclusion>
            </exclusions>
		</dependency>

至此,问题解决。

PS:
mybatis-plus中也自带了分页功能,因此,对于pagehelper没有特殊爱好的话,也可以直接将它去掉,直接使用mybatis-plus分页功能。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

mybatis-plus使用中遇到的问题 的相关文章

随机推荐

  • Android:file.mkdirs() false

    如果创建文件目录失败 就要考虑两个原因 1 是否给了读写权限 清单文件有读写权限 但是创建目录之前是否允许了 span class token operator lt span uses span class token operator
  • 【Flutter web】内网网站如何发布?解决外网下canvaskit.js和字体无法加载问题

    背景 由于部署的网站只能在内网下使用 xff0c 部署服务器又不能访问外网 xff0c 导致Flutter web部署遇到很多问题 xff0c 比如 xff1a 白屏 部署的网站为何首次加载缓慢 xff0c 会白屏 xff1f 通过浏览器开
  • 【Flutter web】实现批量生成可下载的二维码,二维码图片点击下载

    这里写自定义目录标题 先看效果 xff1a 方法 xff1a 先看效果 xff1a 方法 xff1a web布局就略过 xff0c 自行练习 xff0c 只讲重点 xff01 此项目需要用到三个依赖库 xff1a zxing2 0 1 0i
  • android 实现类似个人中心的界面设计

    上效果图 xff1a 先理清设计思路 xff1a 1 外层用linearlayout包裹 xff0c linearlayout采用shape 搭上描边 圆角和填充背景色 2 里层采用relativelayout填充进textview ima
  • 上传项目到github并供团队克隆

    github注册就不说了 1 创建仓库 创建后就能在首页中看到创建的仓库名了 2 本地克隆仓库 到github的项目仓库中找到项目的地址 xff0c 如第一图 磁盘中创建项目文件夹作为仓库 xff0c 右键选择torToiseGit gt
  • Fragment和Activity两种沉浸式状态栏的实现

    我们普通的Activity所有的标题栏颜色风格基本是一致的 xff0c 所以我们可以将这种单独的Activity的沉浸式状态栏放在BaseActivity中实现 但是如果遇到一级栏目的fragment中 xff0c 且有些fragment中
  • Android Studio Git实现回退至某一个版本

    流程 xff1a 一 android studio上部VCS gt Git gt Reset Head 二 选择Reset Type 注释 xff1a Reset Type git reset mixed xff1a 此为默认方式 xff0
  • Gitlab给指定人员设置指定权限

    1 选中指定的项目 xff0c 再选择Members 2 选择要指定的人员 xff0c 选择Project Access xff0c 为其添加指定的权限 xff0c 添加
  • 1.5 Qt Creater使用Python开发桌面软件的程序打包

    当我们开发完成软件后 xff0c 如果需要分发到其它电脑上运行 xff0c 我们需要进行程序打包 通过程序打包 xff0c 我们可以方便其他用户在其它设备上进行程序的使用 最简单且打包文件最小的方式为 xff1a 我们将开发用到的Pytho
  • Vue--Module parse failed: Unexpected character '' (1:0) (fonts/element-icons.ttf)

    当Vue引入iview Element ui后 xff0c npm run dev报错如下图 xff1a 本人项目采用webpack打包工具 xff0c 由于webpack打包工具是将浏览器不能直接运行的拓展语言 xff08 Scss xf
  • 安卓获取APP对应的Android id的原理分析

    android id 的生成原理是由系统生成的随机数 xff0c 并与应用 app 签名 xff0c 经过 HmacSHA256 算法生成的 xff1b 从 android 8 以后开始就是随机的了 xff0c 每个应用获取到的简要步骤 x
  • 将 Word 转换为 Markdown格式 【详细教程】

    文章目录 前言 下载安装Writage Word Markdown 下载安装Pandoc 再次Word Markdown总结 提示 xff1a 以下是本篇文章正文内容 xff0c 学习内容将会持续更新 前言 俗话说 好记性不如烂笔头 在我们
  • JAVA校验SQL语句与格式化语句

    想看实现直接滑倒左下边的工具类 xff0c 前边在说得是解决思路 前言 现在需要向数据库中某张表中的某个字段中 xff0c 插入的值为SQL语句 xff0c 但是要保证插入SQL语句的正确性 xff0c 而且还需要进行格式化 xff0c 就
  • 获取墨墨背单词里面的单词书中的单词

    首先 xff0c 其实是直接尝试抓包获取的 xff0c 不过在抓包的信息中没发现类似的内容 xff0c 然后就去百度了以下 xff0c 发现还是有聪明人 把下载的 apk 文件解压缩一下 xff0c 把里面的 assets 文件夹里面的 m
  • 2021年Redis面试题(持续更新)

    目录 1 redis基础redis 中的数据类型有哪些为什么说redis能够快速执行 2 Redis中的五种数据结构string 字符串 list 列表 set 集合 hash 哈希 zset 有序集合 3 Redis的持久化Redis 的
  • 吐槽一下csdn博客选中文字之后的悬浮窗

    悬浮窗出来的莫名其妙 xff0c 还会挡文字 xff0c 展示一下我框一段文字出现的一百种情况 xff0c csdn是否考虑出一个设置可以自定义把这个功能关闭和开启 看文章很自然的会选中文字一行一行的看 xff0c 我相信很多人都是这样的
  • c语言基础

    基本语法 预定义常量及类型 函数结果状态代码 span class token macro property span class token directive hash span span class token directive k
  • c语言实现基础的排序

    1 插入排序 1 1 直接插入排序 span class token keyword void span span class token function insert sort span span class token punctua
  • 流程图怎么画

    前言 最近在看博客的时候发现很多流程图都不是流程图 xff0c 想画成流程图但是总有些时候会变了样子 xff0c 所以我就想说说流程图到底因该怎么画 组成 流程图一般由由圆角矩形 矩形 菱形 平行四边形 箭头组成 作用 流程图一般都是用圆角
  • mybatis-plus使用中遇到的问题

    mybatis plus使用中遇到的问题 mapper配置问题mybatis plus与mybatis冲突mybatis plus与pagehelper冲突 最近新搭一个测试项目 xff0c 使用了 mybatis plus当前的最新版本