背景

直接使用eclipse工具去执行,没有问题,通过testng.xml去执行,没有问题,但通过mvn clean test执行,就报错,提示org.apache.ibatis.binding.BindingException: Invalid bound statement

解决方法

首先先肯定的是:mybatis的配置是没有问题,因为eclipse可以正常执行;

在eclipse中把mapper的xml文件放到src代码目录下是可以一起打包进classes的,而maven去编译的时候不会,就会导致找不到xml报错。

    • 第一种,由于idea默认是不打包src中的xml文件,所以在eclipse中你可以把xml放到src中没有问题,但是在idea中,你把mapper的xml文件放到resources资源中就可以正常访问!
      这种的话由于代码调整比较大,不建议这样修改;

    • 第二种 在maven配置maven对资源文件的访问,具体做法:在pom中,build节点中加入

      <resources>
          <resource>
              <directory>src/main/resources</directory>
              <includes>
                  <include>**/*.properties</include>
                  <include>**/*.xml</include>
              </includes>
              <filtering>true</filtering>
          </resource>
          <resource>
              <directory>src/main/java</directory>
              <includes>
                  <include>**/*.properties</include>
                  <include>**/*.xml</include>
              </includes>
              <filtering>true</filtering>
          </resource>
      </resources>

      maven在build的时候可以指定resources目录,就可以修复这个问题

通过maven test 报org.apache.ibatis.binding.BindingException: Invalid bound statement的更多相关文章

  1. maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    ssm的项目如果在mapper.xml  mapper接口 配置没问题的情况下  项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...

  2. 项目启动报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wuhongyu.mapper.OrdersMapper.selectByExample

    在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件, 在 ...

  3. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 问题解决方法

    在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件,在p ...

  4. maven 项目报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决

    idea在使用maven构建的项目中使用mybatis时报错org.apache.ibatis.binding.BindingException: Invalid bound statement (n ...

  5. MyBatis笔记----报错:Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法

    报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound st ...

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

  7. 【踩坑】遇到 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 报错

    今天在重做 iblog 客户端时,测试接口情况,发现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...

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

  9. IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.User ...

随机推荐

  1. jvm 加载class文件过程

    jvm 加载class文件分为装载-链接-初始化三个过程. load -------->link verify prepare resolve     ---------->initial ...

  2. MyBatis的关联关系 一对一 一对多 多对多

    一对一示例 一个妻子对应一个丈夫 数据库表设计时 在妻子表中添加一个丈夫主键的作为外键 1 对应的JavaBean代码虽然在数据库里只有一方配置的外键,但是这个一对一是双向的关系. Husband实体 ...

  3. Spring和SpringMVC父子的容器之道---[上篇]

    Spring和SpringMVC作为Bean管理容器和MVC层的默认框架,已被众多WEB应用采用,而在实际开发中,由于有了强大的注解功能,很多基于XML的配置方式已经被替代,但在实际项目中,我们经常会 ...

  4. C++第三篇--程序结构

    C++第三篇--程序结构 1. 初识程序结构 将类中的成员函数全部放在类外实现,类中只负责声明该函数 person.cpp #include <stdio.h> class Person{ ...

  5. docker~docker-compose和VS解决方案的关系

    回到目录 一般地,我们在VS里添加了一个解决方案之后,会更新模块或者业务添加多个api,web项目,这类似于最近说的微服务,而我们的docker-compose与微软件正好有了一种默契,当你为你的解决 ...

  6. mongodb3 ubuntu离线安装(非apt-get)及用户管理

    目前mongodb已经出到3.x,相对于2.x改动较大,本着学新不学旧的原则来捣鼓nosql数据库.最初想着apt-get安装但是软件源上都是2.x的,遂下载好后传到服务器安装. 1.下载 不得不说国 ...

  7. 【Mysql】MySQL与Oracle的大小写问题

    转载来源:http://aofengblog.blog.163.com/blog/static/63170212010101065030136/ MySQL与Oracle在大小写处理上的区别: 1MY ...

  8. OP查阅网站

    1)http://www.zhdba.com/mysqlops/ 2)

  9. JStorm与Storm源码分析(五)--SpoutOutputCollector与代理模式

    本文主要是解析SpoutOutputCollector源码,顺便分析该类中所涉及的设计模式–代理模式. 首先介绍一下Spout输出收集器接口–ISpoutOutputCollector,该接口主要声明 ...

  10. 时间标签DateTime

    1:DateTime类型初始化: DateTime date=new DateTime(2017,01,19,18,23,00);//此内部对应年,月,日,时,分,秒 Console.WriteLin ...