有时候解决问题不仅仅是解决问题。-----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文件的准确性。

 
 

IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的更多相关文章

  1. 完美解决: org.apache.ibatis.binding.BindingException Invalid bound statement (not found)

    异常描述: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 原因: springboot ...

  2. ssm项目dao层方法异常:org.apache.ibatis.binding.BindingException: Invalid bound statement

    在IntelliJ IDEA中用ssm框架搭建了一个demo项目,在执行到dao层方法时抛出这个异常: org.apache.ibatis.binding.BindingException: Inva ...

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

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

  4. idea 单元测试 mybatis spring-test 异常: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    因为在idea中必须在test下才能进行单元测试,所以进行单元测试时,ssm的项目会因为找不到resourece中的配置文件而报错 这里 org.apache.ibatis.binding.Bindi ...

  5. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xyfer.dao.UserDao.findById

    在使用Spring整合MyBatis的时候遇到控制台报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (no ...

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

    在IDEA中将xxxMapper.xml文件创建在(src/main/java)目录中,运行报错:org.apache.ibatis.binding.BindingException: Invalid ...

  7. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误

    我调这个bug调了一天多,在网上搜索的检查namespace,package等,都没有错.错误提示是没有找到xml文件,我就纳闷了,为什么找不到呢?后来才发现,原来是resource中奇怪的目录为题, ...

  8. 【java异常】 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.emptech.db.demo.mapper.master.MOmQuotaTBMapper.findOmQuotaTB

    <mapper namespace="com.emptech.db.demo.mapper.master.MOmQuotaTBMapper"> public inter ...

  9. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement

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

随机推荐

  1. CSS学习笔记:溢出文本省略(text-overflow)

    原文:CSS学习笔记:溢出文本省略(text-overflow) 在CSS3中,text-overflow属性的基本语法如下: clip:表示不显示省略文本,简单的裁切. ellipsis:表示对象文 ...

  2. Windows 7硬盘安装CentOS 6.4 双系统 (WIN7硬盘安装Linux(Fedora 16,CentOS 6.2,Ubuntu 12.04))

     WIN7下硬盘安装Linux(Fedora 16,CentOS 6.2.Ubuntu 12.04) 近期在看<鸟哥私房菜:基础学习篇>.认为非常不错,想要用U盘装个windows 7 和 ...

  3. 使用Castle扩展Ibatis.Net,面向接口编程-更优雅的代码

    使用Ibatis.Net做项目半年了,甚是喜欢,感觉确实是个简单.轻巧的O/R Mapping框架,特别是将Sql配置在Xml文件中,相当于直接将Dao层抽离了出来. 本文假定读者对Ibatis.Ne ...

  4. ajax的post请求

    get和post是http请求方法最主要的两种方式. post: 来个例子test.html <!doctype html> <html lang="en"> ...

  5. wcf契约随记

    1.wcf契约分为:服务契约,操作契约,消息契约.数据契约 -------------------服务契约: [ServiceContract( Name = "name_IUser&quo ...

  6. form-validation--表单验证插件

    基于jquery的validationEngine表单验证插件,根据官网提示,该插件支持IE6-8,Chrome浏览器,火狐,Safari,Opera 10,但由于有使用到了css3的阴影和圆角样式, ...

  7. C# 学习笔记2 C#底层的一些命令运行

    C#在DCP中运行的方法: 1.转到相应的目录 cd d:\1 2.输入csc /target:exe 2.cs 或者 csc /t:exe 2.cs 或者 csc 2.cs 在里边引用外部程序集的方 ...

  8. MVC应用程序请求密码的功能(二)

    MVC应用程序请求密码的功能(二) 在完成<MVC应用程序请求密码的功能(一)>http://www.cnblogs.com/insus/p/3471534.html之后,如果你照着做,所 ...

  9. twisted学习笔记4 部署Twisted 应用程序

    原创博文,转载请注明出处. Twisted是一个可扩展,跨平台的网络服务器和客户端引擎. Twisted Application 框架有五个主要基础部分组成:服务,应用程序,TAC文件插件和twist ...

  10. discuz的门户文章页中增加百度分享代码

    discuz虽然有百度分享插件,但是不太想用,于是自己手动添加了百度分享代码: 一.在http://share.baidu.com/地址中申请设置自己的百度分享代码,选择的风格完全按照个人喜好进行选择 ...