springboot整合mybatis遇到无法扫描MaperScan包的问题
1.启动类加上@MaperScan注解后,一直报错如下:
Error creating bean with name 'platUserMapper' defined in file [D:\workspace\eclipse_data\vivo\target\classes\test\interf\domain\mapper\PlatUserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
原因是pom.xml没有引入如下依赖,因为从SqlSessionDaoSupport 这个类的源码中可以看出,原因是mybatis-spring-1.2.0中取消了自动注入SqlSessionFactory 和 SqlSessionTemplate
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
2.引入如上依赖包后,再次报错,报错如下:
Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.ibatis.session.Configuration.setVfsImpl(Ljava/lang/Class;)V
查看源码发现该类中不存在set方法 ,升级mybatis版本如下:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.4</version>
</dependency>
仍然报错:Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.mybatis.spring.SqlSessionFactoryBean.setVfs(Ljava/lang/Class;)V
升级mybatis-spring:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
更新pom后重新启动,可正常启动。
springboot整合mybatis遇到无法扫描MaperScan包的问题的更多相关文章
- SpringBoot整合Mybatis之项目结构、数据源
已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...
- SpringBoot整合Mybatis【非注解版】
接上文:SpringBoot整合Mybatis[注解版] 一.项目创建 新建一个工程 选择Spring Initializr,配置JDK版本 输入项目名 选择构建web项目所需的state ...
- springboot学习随笔(四):Springboot整合mybatis(含generator自动生成代码)
这章我们将通过springboot整合mybatis来操作数据库 以下内容分为两部分,一部分主要介绍generator自动生成代码,生成model.dao层接口.dao接口对应的sql配置文件 第一部 ...
- springboot整合mybatis出现的一些问题
springboot整合mybatis非常非常的简单,简直简单到发指.但是也有一些坑,这里我会详细的指出会遇到什么问题,并且这些配置的作用 整合mybatis,无疑需要mapper文件,实体类,dao ...
- SpringBoot系列七:SpringBoot 整合 MyBatis(配置 druid 数据源、配置 MyBatis、事务控制、druid 监控)
1.概念:SpringBoot 整合 MyBatis 2.背景 SpringBoot 得到最终效果是一个简化到极致的 WEB 开发,但是只要牵扯到 WEB 开发,就绝对不可能缺少数据层操作,所有的开发 ...
- SpringBoot整合Mybatis完整详细版
记得刚接触SpringBoot时,大吃一惊,世界上居然还有这么省事的框架,立马感叹:SpringBoot是世界上最好的框架.哈哈! 当初跟着教程练习搭建了一个框架,传送门:spring boot + ...
- 【SpringBoot系列1】SpringBoot整合MyBatis
前言: 一直看网上说SpringBoot是解锁你的配置烦恼,一种超级快速开发的框架.一直挺想学的,正好最近也有时间,就学了下 这个是SpringBoot整合MyBatis的一个教程,用了阿里的drui ...
- SpringBoot整合Mybatis之进门篇
已经有好些日子没有总结了,不是变懒了,而是我一直在奋力学习springboot的路上,现在也算是完成了第一阶段的学习,今天给各位总结总结. 之前在网上找过不少关于springboot的教程,都是一些比 ...
- SpringBoot整合Mybatis多数据源 (AOP+注解)
SpringBoot整合Mybatis多数据源 (AOP+注解) 1.pom.xml文件(开发用的JDK 10) <?xml version="1.0" encoding=& ...
随机推荐
- Numpy float64和Python float是一样的
>>> numpy.float64(5.9975).hex() # 函数用于将10进制整数转换成16进制,以字符串形式表示. '0x1.7fd70a3d70a3dp+2' >& ...
- 理解Deadlock
问:为啥以下代码会产生死锁 public class Deadlock { static class Friend { private final String name; public Friend ...
- 2019.04.13 python基础
第一节 主要讲python背景 没什么要注意的 了解记住概念就好 python官网 python.org 自带shell 可以运行python代码 在IDLE中怎么运行代码 新建文本 ...
- Linux下安装whl文件
直接使用pip安装: [root@mycentos ~]# pip install *.whl
- git----------如何创建develop分支和工作流,以及如何将develop上的代码合并到master分支上
1.点击sourceTree 右上角的git工作流,或弹出一个弹出框,无需修改任何东西直接点击确认就可以创建develop. . 2.这里有两个分支了,当前高亮的就是你当前处在的分支.此时develo ...
- 屏幕适配(UGUI)非UI
using UnityEngine; public enum Suit_UIType { Background, Effect, } [RequireComponent(typeof(Transfor ...
- 退出unity运行
public void GetExit()//退出运行 { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false;//用于退 ...
- mysql迁移到data下
http://www.jb51.net/article/47897.htm 由于yum安装mysql的时候,数据库的data目录默认是在/var/lib下,出于数据安全性的考虑需要把它挪到/data分 ...
- Python学习笔记(1)__name__变量
这是我在网上找到的一篇文章的标题. 本着学会了才是自己的,所以标题不变,自己试着再写一遍. 问题:__name__是什么? 背景:在学习编程规范的时候,我被要求函数的调用只能在__main()函数中使 ...
- https://scrapingclub.com/exercise/basic_captcha/
def parse(self, response): # set_cookies = response.headers.getlist("set-cookie").decode(& ...