Junit启动测试mybatis xml文件BindingException: Invalid bound statement问题
背景:1、正常启动,xml文件放在java目录和resource目录下均正常
2、junit启动,xml文件放在resource目录下正常,放在java目录下报BindingException错误
mapperlocation绑定地址为:"classpath:com/a/b/**/*.xml"
原因就在于绑定的地址有问题。
junit生成的test-classes下的测试类test所在目录与classes所在目录相同 都存在com/a/b
启动时首先会找test-classes下的xml,肯定找不到,则不会继续找
所以有两种解决方案:1、路径改为 "classpath*:com/a/b/**/*.xml" 第一个找不到会继续找
2、路径改为 "classpath:com/a/b/c/*.xml" 写全路径
至于放在resource目录下可以找到,是因为xml文件只有在classes下面会存在,所以会顺着路径去找,"classpath:/mapper/**/*.xml"
Junit启动测试mybatis xml文件BindingException: Invalid bound statement问题的更多相关文章
- MyBatis绑定错误--BindingException:Invalid bound statement (not found)
如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...
- 解决 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 以及MyBatis批量加载xml映射文件的方式
错误 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 的出现,意味着项目需要xml文件来 ...
- 【mybatis】mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 或者 feign被调用方使用的mybatis总报空指针异常java.lang.NullPointerException,而变量都没有问题的情况
mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要检查的步骤: ...
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...
- MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup ...
- mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...
- Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...
- Mybatis笔记二:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.dao.N ...
- BindingException: Invalid bound statement (not found)问题排查:SpringBoot集成Mybatis重点分析
重构代码,方法抛出异常:BindingException: Invalid bound statement (not found) 提示信息很明显:mybatis没有提供某方法 先不解释问题原因和排查 ...
- 【spring boot Mybatis】报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.interview.dao.UserMapper.add
报错如下: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.i ...
随机推荐
- CF1408
CF1408 那个博客搭好遥遥无期. A: 直接做就行了,我没智力还写 \(dp\) . #include<bits/stdc++.h> using namespace std; #def ...
- jieba初
url: https://github.com/fxsjy/jieba/blob/master/ jieba "结巴"中文分词:做最好的 Python 中文分词组件 "J ...
- v-imgerror作用:当图片链接无效的时候,显示默认图片内容
// 回顾自定义指令 // 作用: 自定义一些对DOM的操作快捷指令 // 前提: 指令就是用来操作DOM (v-if/v-show/v-for....) // 语法: Vue.directive(指 ...
- 入门级java开发环境的配置安装
为了能够在计算机上开发Java程序和运行Java程序,就需要在Windows操作系统上配置Java开发环境. 首先,安装JDK: 1.在Oracle官网上下载JavaSE: 2.在Download下载 ...
- Github高效搜索方式
Github高效搜索方式 文章目录 Github高效搜索方式 0.写在前面 1.常用的搜索功能 1.1 直接搜索 1.2 寻找指定用户|大小的仓库 1.3 搜索仓库 1.4 查找特定star范围的仓库 ...
- Matlab:读取、写入(.txt)(.xlsx)
写入txt a=[1,2,3;4,5,6]; save C:\Users\Administrator\Desktop\a.txt -ascii a 参考:https://blog.csdn.net/h ...
- vue几种插槽的使用方法
参考文档:https://blog.csdn.net/weixin_49217200/article/details/118496525 参考文档:https://blog.csdn.net/ct52 ...
- Android studio的基本使用--基础篇
一.新建项目 其实跟IDEA新建项目的流程基本一致,File->New->New project,这样就能够新建出来一个项目啦! 一般情况下,我们都会选择Empty Activity,之后 ...
- 服务器资源监测脚本(网卡、MEM、CPU)
#-*- coding: utf-8 -*- #!/usr/bin/python ''' 用法: sar [ 选项 ] [ <时间间隔> [ <次数> ] ] 主选项和报告: ...
- 基于深度学习的鸟类检测识别系统(含UI界面,Python代码)
摘要:鸟类识别是深度学习和机器视觉领域的一个热门应用,本文详细介绍基于YOLOv5的鸟类检测识别系统,在介绍算法原理的同时,给出Python的实现代码以及PyQt的UI界面.在界面中可以选择各种鸟类图 ...