mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大。今天写博客业务代码的时候,犯一个初学者犯过的错误。

错误信息如下:
org.apache.ibatis.binding.BindingException: Invalid bound statement
(not found)

通常原因是因为Mapper interface和xml文件的定义对不上,通常需要检查包名、namespace、函数名等。

出现这个错误的原因是我太过相信自我了,觉得自觉没有错,于是手打,结果就是一个单词写错了。

看代码示例:

xml:

<select id="resentPosts" resultMap="BaseResultMap">
     SELECT post_title FROM `wp_posts` WHERE post_status = ‘publish‘ ORDER BY post_modified DESC LIMIT 0,5
 </select>

dao(interface):

//近期文章
public List<Posts> recentPosts();

大家很容易会看出select标签中的id与dao中的接口函数名不对应。这就是问题的根源,改成一样的,如下(即可解决问题)

<select id="recentPosts" resultMap="BaseResultMap">
      SELECT post_title FROM `wp_posts` WHERE post_status = ‘publish‘ ORDER BY post_modified DESC LIMIT 0,5
  </select>

最后说一句,遇到问题不要慌,找到问题关键信息,复制到百度上/谷歌或者stackoverflow即可找到答案。

太阳底下没有新鲜事儿,你遇到过的,说不定别人也遇到过。

参考链接:https://www.cnblogs.com/lfm601508022/p/InvalidBoundStatement.html

原文地址:https://www.cnblogs.com/youcong/p/10503060.html

时间: 2024-07-29 15:34:04

mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的相关文章

【ide】MyBatis报错: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:225) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65) at org.a

使用springBoot和mybatis整合时出现如下错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方案

在pom.xml文件中添加如下: <build>        <resources>            <resource>                <directory>src/main/java</directory>                <includes>                    <include>**/*.properties</include>          

Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

maven项目使用mybatis时,找不到mapper文件(.xml) 错误信息提示: 项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!! 错误原因: mybatis没有找到对应的请求调用持久层的方法 查错方法: 首先检查target-->classes文件夹被dao层文件夹内是否有对应mapper.xml文件,如果有xml文件,则一般是配置文件出现的错误,如果没有xml类型的文件,则是没有拷贝资源文件的原因.下面是对应的解决方法. 1.名称不一致问题 排查步骤:

错误】org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.baomidou.mybatisplus.mapper.BaseMapper.selectList

maven依赖配置错误<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.2.0</version></dependency> <dependency> <groupId>com.baomidou</groupId>

MyBatis笔记----报错Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

信息: Refreshing org[email protected]41cf53f9: startup date [Wed Apr 05 16:48:12 CST 2017]; root of context hierarchy 四月 05, 2017 4:48:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definiti

spring boot 整合mybatis:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

最近在学习SpringBoot,遇到些异常情况: 1.异常信息 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hippo.demo.dao.Chapter6DemoMapper.insert 2.解决方案 问题找了很久,发现使用@Select.@Insert.@Update.@Delete注解代替xxxMapper.xml里面的内容,不存在异常,那就是扫描xxxMapper

【mybatis】mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要检查的步骤: 1.是否mapper.java文件上使用了注解@Mapper  或者 在启动类上扫描了Mapper类 @MapperScan("com.swapping.springcloud.ms.integral.mapper")   [注意扫描的包名是否正确] 2.注意mapper.xml文件中的

IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227) at org.apache.ibatis.binding.MapperMethod.<init&

MyBatis笔记----报错:Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法

报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectarticle at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at or