背景: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. Oracle11g 修改数据文件路径的方法

    Oracle 修改数据文件路径的方法   1. 关闭数据库,然后启动至mount状态 sqlplus / as sysdba shutdown immediate startup mount 2. 修 ...

  2. Swagger详解

    1.Swagger的介绍 1.1 Swagger的工作原理 1.系统启动,扫描到api工程中的Swagger2Configuration类 2.在此类中指定了包路径,会找到在此包下及子包下标记有@Re ...

  3. MySQL日期date型和int型互换的方法

    一.date型换int型 SELECT UNIX_TIMESTAMP('2017-9-22 13:54:45') 二.int型转date型 SELECT FROM_UNIXTIME(150605968 ...

  4. 白鹭egret 控制屏幕方向

    this.stage.orientation=fangxiang; fangxiang值: portrait landscape auto

  5. ElasticSearch 实现分词全文检索 - term、terms查询

    数据准备 ElasticSearch 实现分词全文检索 - 测试数据准备 ElasticSearch的各种查询 不会对查询关键字进行分词 term 查询 term的查询是代表完全匹配,搜索之前不会对你 ...

  6. 为什么 Go 语言 struct 要使用 tags

    原文链接:为什么 Go 语言 struct 要使用 tags 在 Go 语言中,struct 是一种常见的数据类型,它可以用来表示复杂的数据结构.在 struct 中,我们可以定义多个字段,每个字段可 ...

  7. vivo 短视频用户访问体验优化实践

    作者:vivo 互联网运维团队- Hu Tao 本文介绍了vivo短视频用户访问体验优化的实践思路,并简单讲解了实践背后的几点原理. 一.背景 我们平时在看抖音快手视频的时候,如果滑动到某个视频画面一 ...

  8. NOIP2022游记

    NOIP2022游记 今年是第二次考NOIP了,去年第一次考的时候没学过什么东西,混了个省二.今年以高中生的身份考,不仅仅是要省一,还得拿个不错的名次,任务不小. 考试当天早上校园里的雾很大,不知道会 ...

  9. 最大流应用(Maximum Flow Application)

    1. 二分图匹配(Bipartite Matching) 1.1 匹配(Matching) Def. Given an undirected graph \(G = (V, E)\), subset ...

  10. 手机号码归属地 API 实现防止骚扰电话,看这一篇就够了(内附设计思路和代码)

     在当今时代,骚扰电话已经成为了很多人日常生活中的一个常见问题,严重影响了人们的工作和生活. 为了避免这种情况的发生,企业和机构可以采用手机号码归属地 API,以提供更好的电话服务,减少骚扰电话的出现 ...