引用地址:https://guozh.net/idea-org-apache-ibatis-binding-bindingexception-invalid-bound-statement-not-found/ 这位大哥写的很详细,就拿过来用了

IDEA org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

 2019年4月21日  2条评论  25次阅读  8人点赞

前言

在使用 IDEA 当作工具使用 Mybatis+Spring 时,总是能碰到 Eclipse 碰不到的“蛋疼问题”,这应该是属于 IDEA 的阵痛期,这个错我已经碰到4次了,而且每次原因还不太同。久病成良医,下一次应该不会再出现了,记录下解决办法,希望能帮到你,因为我已经在这个问题上浪费太多时间了。

情况

Mybatis+Spring 配置有好几种方法。最常用的应该是 Mapper 动态代理开发,但是动态代理配置也有两种。

<!-- Mapper代理的方式开发方式一,配置Mapper代理对象 -->
<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<!-- 配置Mapper接口 -->
<property name="mapperInterface" value="cn.itcast.mybatis.mapper.UserMapper" />
<!-- 配置sqlSessionFactory -->
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
    <!-- Mapper动态代理开发 开发方式2   扫描 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.guozh.bitbooks.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>

一般使用第二种,本人也是使用第二种。如果第二种 首先有几点要确定。

  • *Mapper.java 和 *Mapper.xml 命名是否一致
  • 是否在一个包下,扫描能不能扫到 .xml。
  • *Mapper.xml 的 namespace 配置是否准确,接口方法名是否准确。

以上都是 mybatis 的基本知识,当然第二点 可以不再同一个包下。很多种写法,可能有人喜欢将 *Mapper.xml 放在 resources 下。无所谓,只要能扫描到就可以了。
ok 到这里如果还报错如上错误,和我一样,接着看吧

解决

  • 删除编辑后的文件 class,然后 Rebuild 在运行。
  • 如果上面方法不行,仔细找找在编译后的classes 中 *Mapper.xml 生成了没,如果没 那一定有问题。

我的项目结构是这样的,并且 *Mapper.xml 放在 java 中。这里就会有一个问题。

idea默认是不编译 src\main\java下的xml文件

所以这就需要我们手动配置下。

  • 将 *Mapper.xml 复制一份到 resources 下,记得修改 mybatis 配置文件的路径。
  • 在 pom.xml 中配置资源代码
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>

ok 希望能帮到你。

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): da.huying.usermanag ...

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

  3. mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误

    最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...

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

    有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache. ...

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

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

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

  7. Java学习-052-(mybatis+mysql)访问接口时提示:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    在配置mybatis,访问接口提示: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),部 ...

  8. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.shen.mapper.UserMapper.findById

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

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

  10. 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. netcore在CentOS7 下使用处理图片的问题

    请看代码,当你在centos下要把图片转为Base64的时候 MemoryStream ms = new MemoryStream(); try { Bitmap bmp = new Bitmap(f ...

  2. python 内置函数zip,map,三元,lambda表达式

    #内置函数zip(),将多个可迭代对象(集合等)按照顺序进行组合成tuple元祖,放在zip 对象进行存储,: #当参数为空时候,返回空 #如果 zip() 函数压缩的两个列表长度不相等,那么 zip ...

  3. Hive脚本中切勿使用/**/注释

    Hive脚本中切勿使用/**/注释 Hive脚本的注释目前好像只有 -- ,我之前在做初版数据的时候 使用NotePad++ 习惯性的有时候注释会写成 /**/ ,然后就引发了问题 脚本上传到hue, ...

  4. jQuery插件 distpicker实现多次赋值

    项目里需要实现省市区联动选择功能,使用了一个jQuery插件dispicker,记录一下使用过程中遇到的问题和解决办法. 需要要实现的功能就两个:打开modal框时设置地址,点击重置按钮时重置地址 原 ...

  5. feign响应Image流对象

    feign面向方法签名的http调用,越来越受欢迎,类型于rpc的thrift,只需要关注方法签名和返回值即可,当然feign响应流对象时,需要我们做一下特殊处理,否则会出现异常.也有一些文章通过重写 ...

  6. Pull Request 工作流——更高效的管理代码

    目录 Pull Request 工作流--更高效的管理代码 1.问题 2.解决方案 3.Git分支流管理代码具体实施 3.1本地分支操作管理 3.1.1查看分支 3.1.2创建分支 3.1.3切换分支 ...

  7. 小程序封装request请求,统一API

    程序开发中都会调用后端工程师开发的API,小程序的开发文档提供了相对实用的APIwx.request(),但是在开发的过程中,又遇到了一些问题,在小程序的项目开发时,调用的API不止一个,同一个API ...

  8. nodejs环境使用Typeorm连接查询Oracle

    首先是typeorm的官方地址, 国内有人翻了中文版,不保证时效性 ·通过npm安装下列包: typeorm //typeorm连接数据库 @types/node //类型系统 typescript ...

  9. iOS中nil、 Nil、 NULL和NSNull的区别

    参考链接:https://www.jianshu.com/p/c3017ae6684a

  10. 基于django中间件的编程思想

    目录 前言 前期准备 importlib模块介绍 基于django中间件的编程思想 django中settings源码 配置文件的插拔式设计 基于django中间件的思想,实现功能配置 前言 在学习d ...