Springboot+Mybatisplus替换mybatis整合报错Mapped Statements collection does not contain value
问题一:
mybatisPlus完全兼容mybatis,一般来说直接替换掉就可以了,如果mybatis的数据源不能取消创建的话,就注掉mybatisplus的数据源
//@Configuration
public class DataSourceConfig {
// @Bean(name="dataSource2")
// @ConfigurationProperties(prefix="spring.datasource")
public DataSource dataSource(){
return new DruidDataSource();
}
// 配置事物管理器
// @Bean(name="transactionManager2")
public DataSourceTransactionManager transactionManager(){
return new DataSourceTransactionManager(dataSource());
}
}
这个时候一般启动就没问题了,但是在调用原来的数据库方法是,可能会报错:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for xx.xxx.xx.listBy
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for xx.xxx.xx.listBy
这个时候看看application.yml中的
mybatis-plus.mapper-locations=classpath:/mybatis/mapper/*.xml路径格式是否加上,与mybatis属性名不一样,
问题二:
对于引用的第三方依赖包,其中有使用到数据库查询的,也可能报这个错,原因在于moudle1引用moudle2,moudule2引用moudle3,
而mybatisplus是在moudle3中引用的,当moudle1加载的时候是先加载2,和3,之后再加载moudle1中的其他第三方依赖,这个时候mybatisplus就扫描不到第三方的mapper,从而导致查询报错
解决方法,将第三方依赖已到moudle2中,这样就能扫描了,同时修改mybatisplus的扫描路径为
mybatis-plus.mapper-locations=classpath*:/mybatis/mapper/*.xml
Springboot+Mybatisplus替换mybatis整合报错Mapped Statements collection does not contain value的更多相关文章
- Spring+Mybatis整合报错Mapped Statements collection does not contain value原因之一
报错如下: ### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements coll ...
- mybatis启动报错Mapped Statements collection already contains value for com.autoyol.mapper.trans.TransDispatchingMapper解决
1.检查sqlsession配置,在applicationContext文件中.检查mybatis配置文件. 2.检查TransDispatchingMapper.java 是接口类,无注解. 3.T ...
- mybatis报错Mapped Statements collection does not contain value for com.inter.IOper
首页 > 精品文库 > mybatis报错Mapped Statements collection does not contain value for com.inter.IOper m ...
- 报错Mapped Statements collection does not contain value for com.atguigu.mybatis.dao.EmployeeMapperPlus
报错Mapped Statements collection does not contain value for com.atguigu.mybatis.dao.EmployeeMapperPlus ...
- Mybatis报错——Mapped Statements collection already contains value for
解决办法: 看看你的mybatis-config.xml <mappers> <mapper resource="mapper/SeckillDao.xml&quo ...
- SpringBoot和mybatis整合报错:Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 152; columnNumber: 10; 元素类型为 "mapper"
很明显,报错是xml有问题,于是去检查,发现: 由于粗心,保存的时候,按的太频繁,多按了个s在里面,导致启动报错!
- spring和mybatis整合报错:org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError
Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyExceptio ...
- mybatis启动报错Result Maps collection already contains value forxxx
ssm搭建过程中启动tomcat,报错: Cause: java.lang.IllegalArgumentException: Result Maps collection already conta ...
- SpringBoot+MyBatis整合报错Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
项目启动的时候报这个错误,这个问题我百度了一天,果然不出意外的还是没能解决,其中有一篇文章相对来说还是有点用的:https://blog.csdn.net/qq8693/article/details ...
随机推荐
- 字体小于12px 无法缩小解决方案
通过缩放进行大小控制. 缩放可能会导致元素也进行缩放.需要注意 transform: scale(0.5);
- bzoj4025-二分图【线段树分治,并查集】
正题 题目链接:https://darkbzoj.tk/problem/4025 题目大意 \(n\)个点\(m\)条边,每条边会在一个\(T\)以内的时间段内出现,对于任意一个\(T\)以内的时刻求 ...
- Redux使用指南
Redux使用指南 00-简介 本文主要是用来记录Redux结合React的使用过程,帮助大家在使用Redux的时候,能够更好的理解Redux,从而更好地使用它 01-为什么需要Redux JavaS ...
- Docker部署Mysql,如何开启binlog
0.拉取镜像 sudo docker pull mysql:5.7 1.创建存放映射文件夹 mkdir -p mydata/mysql/log mkdir -p mydata/mysql/data m ...
- Fortran学习笔记:01 基本格式与变量声明
Fortran学习笔记目录 01 基本格式与变量声明 格式 固定格式(Fixed Format):Fortran77 程序需要满足一种特定的格式要求,具体形式参考教材 自由格式(Free Format ...
- pip 命令总结
建议和 Conda 命令一起看,pip 和conda命令有点相似.<Conda 命令> 1 查看帮助文档 pip --help 使用该命令将告诉你 pip 的常用命令. 使用时,输入pip ...
- 题解 CF241E Flights
题目传送门 题目大意 给出一个 \(n\) 个点 \(m\) 条边的 \(\texttt{DAG}\) ,给每条边设定边权为 \(1\) 或者 \(2\) ,使得 \(1\to n\) 的每条路径长度 ...
- SpringBoot入门03-转发到Thymeleaf
前言 Spring Boot不提倡使用jsp和用View层,而是使用Thymeleaf代替jsp,因为性能可以得到提升. 使用Thymeleaf要加入依赖 Thymeleaf不能直接被访问,它严格遵守 ...
- 一个简单的单例模式Demo
/** * @author :nx014924 * @date :Created in 5/30/2021 1:09 PM * @description: * @modified By: * @ver ...
- CentOS 文件管理
目录 目录管理 目录结构 切换目录 查看目录 创建目录 复制目录 剪切目录 删除目录 文件管理 查看文件 创建文件 复制文件 剪切文件 删除文件 创建链接 目录管理 目录也是一种文件. 蓝色目录,绿色 ...