原因: 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的。由于maven工程在默认情况下src/main/java目录下的mapper文件是不发布到target目录下的。

解决方法

  在dao的pom.xml中添加如下内容:

<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>

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映射文件有错误。但是这个提示不一定准确,以致网上有些资料说这个问题很奇怪。出现这个错误一般的解决方式在下面有说明:
 
一般的原因是Mapper interface和xml文件的定义对应不上,需要检查包名,namespace,函数名称等能否对应上,需要比较细致的对比。
 
按以下步骤一一执行:
1:检查xml文件所在的package名称是否和interface对应的package名称一一对应
2:检查xml文件的namespace是否和xml文件的package名称一一对应
3:检查函数名称能否对应上
4:去掉xml文件中的中文注释
5:随意在xml文件中加一个空格或者空行然后保存(触发了ide的自动编译功能。由于xml文件在编译的时候,不一定总能立即从源目录复制到class文件的编译目录(MyEclipse经常出这个问题),有时候你源目录中的xml文件已经修改好了,而class所在的目录里面还是旧的。因此真正确定有效的方式是将正确的xml文件复制到class输出目录。)
 
(博主使用IDEA工具)
但是博主在尝试以上方案之后仍然报错,在我查看了发布之后的源代码之后,发现*Mapper.xml文件并没有发布到目标文件中。
如图所示:
Mapper目录:

发布之后target目录中:

居然没有xml文件,突然意识到了异常的原因:

idea中我将mapper类型是source,而xml文件在发布时不会编译,同时也不会发布到target中,导致项目运行时找不到mapper.xml文件。

解决方案:我将*Mapper.xml文件提取到指定文件夹mapper中,设置mapper文件夹类型为resource,在application-dao.xml配置文件中添加图片中框选的代码对mapper文件进行扫描。问题解决。

总结:

(1)eclipse、myeclipse、idea针对项目的文件处理方式不一样。

eclipse和myeclipse中mapper.java和mapper.xml在同一目录下,直接配置扫描不会出现上述问题。

(2)注意xml文件的准确性。

参考:https://www.cnblogs.com/jstarseven/p/5803697.html

Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement的更多相关文章

  1. HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    今天整合ssm框架 时 遇到的问题 困扰我好长时间     原因就是  mapper文件 没有被加载进来 但是 为什么没有被加载进来呢  因为中间的配置文件出了一些问题 网上大多数说法是   在pom ...

  2. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b

    Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b ...

  3. spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingExcept ...

  4. HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException

    在使用Maven工程管理工具整合SSM框架时,Mybatis使用逆向工程生成的pojo,mapper接口及映射文件,把mapper接口和映射文件放在DAO工程的同一级src/main/java目录下. ...

  5. Exception:Request processing failed; nested exception is org.apache.ibatis.binding.BindingException

    异常 在测试Spring MVC+Mybatis整合时,运行 Maven build -> tomcat7:Run 遇到如下异常 从异常信息上看,是找不到mapper对应的xml文件,于是我到t ...

  6. [springMVC - 1A] - Request processing failed; nested exception is org.apache.ibatis.builder.IncompleteElementException

    一月 14, 2016 1:30:07 下午 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for ...

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

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

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

随机推荐

  1. 【原创】10. MYSQL++ 之 DbDriver

    1. 综述 DbDriver只是对于MYSQL C API的一个非常简单的封装,作者原句是This class does as little as possible to adapt between ...

  2. rsync 服务器架设方法

    作者: 北南南北 来自:Linuxsir.Org 摘要: rsync 是一个快速增量文件传输工具,它可以用于在同一主机备份内部的备分,我们还可以把它作为不同主机网络备份工具之用.本文主要讲述的是如何自 ...

  3. TOP命令 详解CPU 查看多个核心的利用率按1

    top命令是linux下常用的工具,可以查看各个进程的CPU使用情况.先看一个实例: 这是Ramnode双核VPS的top显示结果: 左上角可以看到CPU的使用率是11.3%,但是看下面的进程,plu ...

  4. Cloudstack动态修改CPU、内存

    环境: CentOS6.4+Cloudstack4.2+xenserver 6.2 动态修改Cloudstack guest 内存.CPU 准备工作: 1.安装 xenserver tools工具包 ...

  5. linux Shell中常用的条件判断

    linux Shell中常用的条件判断 -b file            若文件存在且是一个块特殊文件,则为真 -c file            若文件存在且是一个字符特殊文件,则为真 -d ...

  6. 特征选择Boruta

    A good feature subset is one that: contains features highly correlated with (predictive of) the clas ...

  7. HDU 5293 Tree chain problem

    树状数组 + dp 设$f_i$表示以$i$为根的子树中的能选取的最大和,$sum_x$表示$\sum_{f_y}$  ($y$是$x$的一个儿子),这样子我们把所有给出的链按照两点的$lca$分组, ...

  8. 关于Rest Framework中View、APIView与GenericAPIView的对比分析

    关于Rest Framework中View.APIView与GenericAPIView的对比分析  https://blog.csdn.net/odyssues_lee/article/detail ...

  9. .html与.text的异同

    .html与.text的方法操作是一样,只是在具体针对处理对象不同 .html处理的是元素内容,.text处理的是文本内容 .html只能使用在HTML文档中,.text 在XML 和 HTML 文档 ...

  10. Mybaties原理图