背景: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问题的更多相关文章

  1. MyBatis绑定错误--BindingException:Invalid bound statement (not found)

    如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...

  2. 解决 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 以及MyBatis批量加载xml映射文件的方式

    错误 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 的出现,意味着项目需要xml文件来 ...

  3. 【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) 需要检查的步骤: ...

  4. mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误

    最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...

  5. 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 ...

  6. mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...

  7. Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...

  8. 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 ...

  9. BindingException: Invalid bound statement (not found)问题排查:SpringBoot集成Mybatis重点分析

    重构代码,方法抛出异常:BindingException: Invalid bound statement (not found) 提示信息很明显:mybatis没有提供某方法 先不解释问题原因和排查 ...

  10. 【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 ...

随机推荐

  1. NOIP2015普及组

    T1 金币 很简单的题,控制天数这个变量 #include<iostream> #include<cstring> #include<cmath> #include ...

  2. OperationContext

    public void Add(double x, double y) { double result = x + y; ICallback callback = OperationContext.C ...

  3. SQL Server之Cross apply

    1 --这样是不行的 2 select sys.dm_exec_sql_text(most_recent_sql_handle) from sys.dm_exec_connections 3 4 -- ...

  4. 解决Vue打包后背景图片路径错误问题(转)

    1.原因解析 当用vue-cli自动构建项目后,有两种运行方法,分别是: npm run dev : 提供一个开发的环境,自动热更新,资源使用绝对路径,所以可以正常看到背景图片. npm run bu ...

  5. 复制文本到粘贴板 (vue3)(兼容ios)

    // 点击复制到剪贴板 const copyToClipboard = (content)=> { if (window.clipboardData) { window.clipboardDat ...

  6. NX二次开发 拔模增量计算工具

    在塑胶模具设计行业拔模增量计算经常都需要用到,平常都是利用计算器工具或者外部的计算工具去算.曾经有一个模具设计的培训老师把拔模增量计算工具称为模具设计的神器,好吧,我也造个神器.-_-! VS2019 ...

  7. 安装单机版k8s

    1.配置yum源,博主使用华为的镜像源 选择不同的系统版本下载使用: 2.安装etcd,kubernetes yum -y install etcd kubernetes 3.修改kubernetes ...

  8. Python学习笔记--PySpark的相关基础学习(一)

    PySpark包的下载 下载PySpark第三方包: 构建PySpark的执行环境入口对象 PySpark的编程模型 数据输入 对于SparkContext对象里面的成员方法parallelize,支 ...

  9. 实践Pytorch中的模型剪枝方法

    摘要:所谓模型剪枝,其实是一种从神经网络中移除"不必要"权重或偏差的模型压缩技术. 本文分享自华为云社区<模型压缩-pytorch 中的模型剪枝方法实践>,作者:嵌入式 ...

  10. 从零开始学习Java系列之Java运行机制与跨平台特性

    全文大约[4000]字,不说废话,只讲可以让你学到技术.明白原理的纯干货!并带有丰富的案例及配图,让你更好地理解和运用文中的技术概念,给你带来具有足够启迪的思考-- 在上一篇文章中,壹哥给大家介绍了J ...