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 ...
随机推荐
- django_静态文件
**************************************************************************************************** ...
- js字符串常用的方法
1. charAt( ) 获取指定下标处的字符 let str = 'hello' console.log(str.charAt(0));//h 2. charCodeAt 获取下标出的字符的Un ...
- java: javacTask: 源发行版 8 需要目标发行版 1.8
idea同一工作空间中不同工程使用不同的jkd版本.在本地idea同时使用jdk1.7和jdk1.8,不同的java工程使用不同的jdk版本,但是在java代码编译时报错,其报错信息为:[java: ...
- Vue中 ref、$refs区别与使用
定义2个组件: 子组件ChildrenSubRef.vue: 1 <template> 2 <div> 3 4 </div> 5 </template> ...
- 飞桨AI 文本实体抽取 数据准备(excel 文本标注)
网纸: https://ai.baidu.com/easydl/app/deploy/tee/public #!/usr/bin/env python3 # -*- coding: utf-8 -*- ...
- 获取请求结果中json数据的值
import json with open("config.json", "r") as f: your_dict = json.loads( ...
- win10、win11安装子系统kali linux、图形化界面的安装
1.开启安装Linux子系统需要的扩展 Win+Q搜索功能 勾选需要的扩展,Hyper-V.Windows 虚拟机监控平台.适用于Linux的Windows子系统.虚拟机平台 反正这些有关于虚拟机的全 ...
- Android笔记--通过MediaStore查询图片
相关描述 已经完成发送彩信功能之后,就来继续向前走一步,来到MediaStore查询图片界面啦! 具体步骤实现 1.简简单单地一个界面 <?xml version="1.0" ...
- Java并发小结01
Java并发小结01 主要参考自<实战Java高并发程序设计>. 需要知道的概念 - 同步与异步 - 并发与并行 - 临界区 - 阻塞与非阻塞 - 死锁.饥饿.活锁 同步与异步 同步:同步 ...
- SQL注入,Hacker入侵数据是如何做到的
什么是SQL注入? SQL注入就是未将代码与数据进行严格的隔离,导致在读取用户数据的时候,错误地把黑客注入的数据作为代码的一部分执行. SQL注入自诞生以来以其巨大的杀伤力闻名. 例子: 典型的SQL ...