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=& ...
 
随机推荐
- [js]jquery里的jsonp实现ajax异源请求
			
同源请求-jquery <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/ ...
 - [svc]共享内存
			
ipc是什么? 进程间通信(IPC,Inter-Process Communication),指至少两个进程或线程间传送数据或信号的一些技术或方法. 进程间为何不能直接共享数据? 如何解决ipc问题? ...
 - aws cloudwatch监控怎么通过钉钉机器人报警
			
最近在完善海外业务在aws服务的CloudWatchh监控,发现CloudWatch报警通知要通过aws的sns服务,直接支持的通道有短信和邮件,但是我们想推到钉钉群里面的群机器人里面这个就要借助aw ...
 - arithmetic-02
			
Java collection API 中实现的表ADT: collection<E>接口实现继承iterable<E>接口,实现iterable接口的类可以使用增强for循环 ...
 - mysql 事务锁超时时间 innodb_lock_wait_timeout
			
mysql 事务锁超时时间 innodb_lock_wait_timeout: # 查询全局等待事务锁超时时间 SHOW GLOBAL VARIABLES LIKE 'innodb_lock_wait ...
 - Flutter 控件之 Routes 和 Navigator.    [PopupRoute]
			
一个 App 通常会有多个界面,每个界面实现不同的功能,并在多个界面之间跳转.在 Flutter 中多个界面的跳转是通过 Navigator 来实现的. 在 Flutter 中定义了一个 Overla ...
 - java web 的 几种跨域方式
 - 剑指offer(63)数据流中的中位数
			
题目描述 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值.如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值.我们 ...
 - topcoder srm 580 div1
			
problem1 link 最优选择一定是在$2n$个端点中选出两个. problem2 link 分开考虑每个区间.设所有区间的左端点的最大值为$lc$,所有区间的右端点的最小值为$rc$.对于某个 ...
 - G711 G723 G729线路占多少带宽问题
			
G.711 G.711 也称为PCM(脉冲编码调制),是国际电信联盟订定出来的一套语音压缩标准,主要用于电话.它主要用脉冲编码调制对音频采样,采样率为8k每秒.它利用一个 64Kbps 未压缩 ...