引用地址: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. SAP中的数据库表索引

    数据库表中的索引可以加快查询的速度.索引是数据库表字段的有序副本.附加的字段包含指向真实数据库表行的指针.排序可以使访问表行的速度变快,例如,可以使用二分搜索.数据库表至少有一个主索引,由它的key字 ...

  2. 林克的小本本之——HCL网络知识随笔

    单臂路由 单臂路由是一种通过在路由器的一个接口上配置逻辑接口,来实现不同Vlan之间互通的方法. 实例: #配置SW1的VLAN [SW1]vlan 2 #配置端口vlan略 [SW1]int g1/ ...

  3. linux 文件管理命令

    一,文件查看more,less,head,tail,cat,tac 分屏查看文件内容 more:和man用法一样,但翻屏到尾部自动推出. less:和man用法一样. head:查看文件的前n行.n默 ...

  4. Dockerfile制作镜像

    Dockerfile简介 dockerfile 是一个文本格式的配置文件, 用户可以使用 Dockerfile 来快速创建自定义的镜像, 另外,使用Dockerfile去构建镜像好比使用pom去构建m ...

  5. Eureka 入门,带视频

    疯狂创客圈 Java 高并发[ 亿级流量聊天室实战]实战系列 [博客园总入口 ] 架构师成长+面试必备之 高并发基础书籍 [Netty Zookeeper Redis 高并发实战 ] 前言 Crazy ...

  6. jQuery-验证码倒计时的实现

    点击发送验证码,通常需要加入倒计时功能,HTML如下: <center class='block captchaArea'> <input class="input pwd ...

  7. IT兄弟连 HTML5教程 DIV+CSS网页标准化布局 小结及习题

    小结 DIV+CSS布局页面的优势:表现和内容相分离.代码简洁,提高页面浏览速度.易于维护和改版.提高搜索引擎对网页的索引效率.每个HTML元素都可以看作一个区块,类似于装了东西的盒子,称为盒子模式. ...

  8. C# List 根据对象属性去重的四种方法对比

    测试代码: private void TestDistinct() { Task.Run(() => { //生成测试数据 DateTime dt = DateTime.Now; Random ...

  9. vue--CRUD

    1. Create this.$http.post("http://localhost:3000/users",newCustomer).then(function (respon ...

  10. Dynamics 365-当OrganizationServiceProxy是Null的时候

    不少从事D365研发工作的朋友,可能或多或少都经历过这么一种情况,使用CrmServiceClient对象初始化一个实例,然后发现OrganizationServiceProxy对象是null.不仅如 ...