首页 > 其他分享 >org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

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

时间:2023-04-17 16:47:45浏览次数:34  
标签:xml mapper 文件 binding bound statement found

1.问题

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

Springboot项目中,在mybatis中mapper数据库操作接口(有的称DAO,有的直接说mapper,都只同一文件)与mapper配置文件在做映射绑定的时候出现问题,简单说,就是接口与xml要么是找不到,要么是找到了却匹配不到。

2.原因导致 Invalid bound statement (not found)的可能原因有:

1)xml文件所在package名称和mapper interface所在的package name不一致,mapper 的namespace写的不对,需要修改。

mapper映射的xml文件示例:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.dao.IDemoMapper">
 
</mapper>

2)  mapper 接口文件在映射的xml文件中没有,执行对应方法后报 Invalid bound statement (not found)。

xml文件标签的id名与mapper接口中的方法名保持一致.

3)mapper接口文件中的返回值为定义的POJO时,select元素中没有正确配置ResultMap,或者只配置了ResultType

4)mapper的xml文件配置路径不正确。SpringBoot要扫描到mapper静态资源文件即xml文件,需要添加配置类 (加@Mapper注解,这个不用配置了)

@Configuration
@MapperScan("com.example.demo.mapper")
public class MyBatisConfiguration {
}

5.要把source/mapper这些文件编译到class类下,需要在pom文件中<build></build>添加如下.来保证文件都能正常被扫描到并且加载成功.

<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
        <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
</resources>

 

 

 

转: https://blog.csdn.net/qq_43780761/article/details/126494026

 

标签:xml,mapper,文件,binding,bound,statement,found
From: https://www.cnblogs.com/fps2tao/p/17326332.html

相关文章

  • WPF中Binding使用StringFormat格式化字符串方法
    https://blog.csdn.net/weixin_34040079/article/details/89587412 原文: WPF中Binding使用StringFormat格式化字符串方法 货币格式<TextBlockText="{BindingPrice,StringFormat={}{0:C}}"/>//$123.46货币格式,一位小数<TextBoxText="{BindingPrice,Str......
  • Android深入学习之LayoutInflater类和ViewBinding
    在build.gradle(Module)中添加viewBinding元素后,Android会自动给模块中的每个XML布局文件生成一个相应的Binding类,该Binding类名称为XML布局文件驼峰式大写+Binding后缀。以如下所示的activity_welcome.xml文件为例,对应的ActivityWelcomeBinding.java的源代码如下所示。<?xmlv......
  • 浅析DNS Rebinding
    0x01攻击简介DNSRebinding也叫做DNS重绑定攻击或者DNS重定向攻击。在这种攻击中,恶意网页会导致访问者运行客户端脚本,攻击网络上其他地方的计算机。在介绍DNSRebinding攻击机制之前我们先了解一下Web同源策略,Web同源策略同源策略(英语:Same-originpolicy)是指在Web浏览器中,允......
  • 重构——搬移语句到调用者(Move Statements to Callers),其反向重构:搬移语句到函数(213)
    8.4搬移语句到调用者(MoveStatementstoCallers)反向重构:搬移语句到函数(213)emitPhotoData(outStream,person.photo);functionemitPhotoData(outStream,photo){outStream.write(`<p>title:${photo.title}</p>\n`);outStream.write(`<p>location:${photo......
  • JDBC-API详解--PreparedStatement
    PreparedStatement作用:1.预编译sql语句并执行:预防sql注入问题·sql注入sql注入是通过操作输入来修改事先定义好的sql语句,用以执行代码来对服务器进行攻击的方法写法: Stringsql="select*fromuserwhereusername=?andpassword=?";//注意参数要写成问号。Prep......
  • Invalid bound statement (not found)错误解决方法
    在ruoyi后端的代码学习过程中,代码运行遇到Invalidboundstatement(notfound)错误基本的错误网上大佬众多,总结的也比较全面,可以参考,但是通过检查在代码方面没有任何问题,通过查找资料,找到了问题所在,关键在于以下方面重点众所周知,现在建立xml文件一定是在resources文件下建立一......
  • 渡一教育_Java每日一练:建立Statement的作用是什么、前端Console.log( Boolean(‘‘))
    系列文章目录文章目录系列文章目录题目1java部分建立Statement的作用是什么(答案在最后公布)题目1-答案==解析====答案==题目2前端js部分==答案==题目3前端js部分如下代码输出的是什么答案和解析如下==解析==题目4如果希望1监听TCP端口为9000,服务端应该怎样创建socket题目答......
  • java.sql.SQLException: sql injection violation, multi-statement not allow?已解决
    今天在使用mybatis-oracle时有需求需要同时更新多个字段,在跑完接口后我发现有如下异常sqlinjectionviolation,multi-statementnotallow原因是没有配置allowMultiQueries=truespringboot项目直接在配置文件写上如下配置即可还有用config类来解决的在配置类中添加如下两......
  • 38、K8S-安全机制-RBAC之(cluster)role、(cluster)rolebinding
    1、RBAC1.1、基本简介1.1.1、简介RBAC使用rbac.authorization.k8s.ioAPIGroup来实现授权决策,允许管理员通过KubernetesAPI动态配置策略。Kubernetes的基本特性就是它的所有资源对象都是模型化的API对象,我们可以基于api-server对各种资源进行增、删、改、查等操作,但......
  • Element.getBoundingClientRect()
    Element.getBoundingClientRect() 方法返回一个 DOMRect 对象,其提供了元素的大小及其相对于视口的位置。参考:https://developer.mozilla.org/zh-CN/docs/Web/API/Elem......