玩了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 ,
</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 ,
</select>

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

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

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

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

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

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

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

    在pom.xml文件中添加如下: <build>        <resources>            <resource>                & ...

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

    maven项目使用mybatis时,找不到mapper文件(.xml) 错误信息提示: 项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!! 错误原因: mybatis没有 ...

  4. 使用maven整合mybatis时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    分析原因是mybatis的映射文件的问题,首先进行分析排查: 1.检查mapper接口和对应的xml文件的包名是否对应 2.检查xml文件的namespace与mapper接口的包名是否对应 3.检查 ...

  5. Spring boot结合mybatis开发的报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),经过排查确定是没有找到xml的原因 ...

  6. maven 项目报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决

    idea在使用maven构建的项目中使用mybatis时报错org.apache.ibatis.binding.BindingException: Invalid bound statement (n ...

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

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

  8. Mybatis笔记二:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    错误异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.dao.N ...

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

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

随机推荐

  1. 贝塞尔曲线与CSS3动画、SVG和canvas的应用

    简介 贝塞尔曲线是可以做出很多复杂的效果来的,比如弹跳球的复杂动画效果,首先加速下降,停止,然后弹起时逐渐减速的效果. 使用贝塞尔曲线常用的两个网址如下: 缓动函数:http://www.xuanfe ...

  2. 小tips:JS语法之标签(label)

    JavaScript语言允许,语句的前面有标签(label),相当于定位符,用于跳转到程序的任意位置,标签的格式如下. label: statement 标签可以是任意的标识符,但是不能是保留字,语句 ...

  3. SAP MM 没有维护MRP 视图的物料可以正常参与采购业务

    SAP MM 没有维护MRP 视图的物料可以正常参与采购业务 Material number: R000006872,没有维护MRP 视图, ​ 也就是没有指定该物料来源是采购还是自制.此种情况下,S ...

  4. windows10系统关闭自动更新服务

    一.关闭Windows10系统的自动更新服务 1:使用快捷键Win+R,打开运行 2:输入命令:services.msc,打开系统服务界面 找到Windows Update双击 将启动类型改为[禁用] ...

  5. Ubuntu、deepin 安装 mysql

    在 Ubuntu 和 deepin 安装 mysql 是很简单的,只需要几条简单的命令即可   1. sudo apt-get install mysql-server 2. sudo apt-get ...

  6. IntelliJ IDEA 编译Java程序出现 'Error:java: 无效的源发行版: 9' 的解决方案

    最新安装的IntelliJ IDEA 2018.1编译器,创建Java Project,并选择之前安装好的Eclipse配置的JDK,如图所示: 在工程中添加 Main.class, main函数中写 ...

  7. Android ScrollView内部组件设置android:layout_height="fill_parent"无效的解决办法

    问题:scrollview内部组件都设置了android:layout_height="fill_parent"却没有效果. 解决办法:设置scrollview的fillViewp ...

  8. 2059-authentication plugin 'caching_sha2_password"cnnot bt loaded :mysql8.0数据库链接不上:

    问题:最近数据库出了问题,就重新安装了数据库8.0,8.0建立数据库时出现问题,错误提示: 2059-authentication plugin 'caching_sha2_password" ...

  9. 使用 float 存储小数?

    很多程序员就会使用 float 类型来存储小数.sql 的 float 类型和其他大多数编程语言的 float 类型一样, 根据IEEE 754 标准使用二进制格式编码实数数据. 但是很多程序员并不清 ...

  10. spring4笔记----常见的java的字符类型与xml匹配

    private List<String> schools; <property name="schools"> <list> <value ...