引用地址: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. RMAN备份数据库与表空间

    脚本: 数据库备份: backup database format='/u01/app/oracle/oradata/Backup/oradb_%d_%s.bak'; 表空间备份:backup tab ...

  2. Pycharm导入Django项目

    Pycharm导入Django项目 添加项目:file-->open,找到项目所在的位置打开项目 添加django后台项目路径 file-->settings-->Languages ...

  3. 微信 电脑版 HOOK(WeChat PC Hook)- 远程线程注入dll原理

    Windows加载dll的特性 1.Windows系统中,每个exe软件运行的时候,会加载系统模块kernel32.dll 2.所有加载进exe软件的系统模块kernel32.dll,内存地址都是一样 ...

  4. python语言的鸭子类型和强类型语言的多态

    python语言的鸭子类型和强类型语言的多态 前面讲接口类的时候举过一个有关支付方式的例子,支付方式可以有几种,微信支付,支付宝支付,苹果支付等,这几个不同的支付都统一于支付,像这样几个类都统一于 某 ...

  5. 第1章:C++泛型技术基础:模板——《C++泛型:STL原理和应用》读书笔记整理

    第1章:C++泛型技术基础:模板 1.2 关于模板参数 1.2.1 模板参数类型 类型参数   typename声明的参数都属于类型参数,它的实参必须为系统内置或者用户自定义的数据类型,包括类模板实体 ...

  6. 记一个AbstractMethodError

    如下,引入FastJsonHttpMessageConverter 之后,导致了新的错误: @Override public void configureMessageConverters( List ...

  7. MySql数据库基础之数据库简介及安装

    MySql数据库简介: 众所周知,MySql数据库是一款开源的关系型数据库,在Web应用方面,MySql是最好的.最流行的RDBMS(Relational Database Management Sy ...

  8. 一文理解Java IO/NIO/AIO

      目录 概述 一.IO流(同步.阻塞) 二.NIO(同步.非阻塞) 三.NIO2(异步.非阻塞) 正文 概述 在我们学习Java的IO流之前,我们都要了解几个关键词 同步与异步(synchronou ...

  9. VO(视图模型) 与 DTO(数据传输对象)的区别

    目录 VO(视图模型) 与 DTO(数据传输对象)的区别 1.VO与DTO概念 2.VO 视图模型的必要性与解耦 2.1 视图模型 2.2 视图模型存在的必要性 2.3 视图模型的解耦 3.DTO 存 ...

  10. Git实战指南----跟着haibiscuit学Git(第九篇)

    笔名:  haibiscuit 博客园: https://www.cnblogs.com/haibiscuit/ Git地址: https://github.com/haibiscuit?tab=re ...