通过maven test 报org.apache.ibatis.binding.BindingException: Invalid bound statement

背景

直接使用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目录,就可以修复这个问题

时间: 2024-12-23 08:02:54

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

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

报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectarticle at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at or

【mybatis】mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要检查的步骤: 1.是否mapper.java文件上使用了注解@Mapper  或者 在启动类上扫描了Mapper类 @MapperScan("com.swapping.springcloud.ms.integral.mapper")   [注意扫描的包名是否正确] 2.注意mapper.xml文件中的

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.UserMapper.findAll at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227) at org.apache.ibatis.binding.MapperMethod.<init&

MyBatis笔记----报错Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

信息: Refreshing org[email protected]41cf53f9: startup date [Wed Apr 05 16:48:12 CST 2017]; root of context hierarchy 四月 05, 2017 4:48:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definiti

springboot项目下的Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

今天遇到mybatis-puls的报错Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 排查方法如下: 1.mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)? 2.mapper.xml的命名空间(namespace)是否跟mapper接口的包名一致? 3.接口的方法名,与xml中的一条sql标签的id一致 4.配置

IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found... 一开始以为是自己配置文件写的有问题找了半天也没有问题,之后才发现是自己对IDEA工具使用的不够熟悉. 先说该异常常见解决方案: 一般是xml映射文件有错误.但

转:IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

原文地址:https://www.cnblogs.com/jstarseven/p/5803697.html 有时候解决问题不仅仅是解决问题.-----jstarseven 最近采用了开发工具IDEA开发SSM开发框架完成后,发布的时候出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found... 一开始以为是自己配置文件写的有问题找了半天也没有问题,之后才发现是自己对IDEA工具使用的不够熟

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.e3mall.search.mapper.ItemMapper.getItemList

java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.e3mall.search.mapper.ItemMapper.getItemListorg.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.e3mall.sear

Exception:HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

主要错误信息如下: HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) description The server encountered an internal error that prevented it from fulfilling this request. exception java.lang.RuntimeException: org