SpringBoot:Invalid bound statement (not found)的原因和解决方案

简介: SpringBoot:Invalid bound statement (not found)的原因和解决方案

🐓 报错信息:

(无效绑定声明)找不到

image.png

解析:

你的mapper实例对象和对应的mapper.xml对象未找到


🐓 排查:

情况一:

1.排除相对应的mapper实例对象路径是否正确

1278d8a05c5844788c7b32532c3209c5.png

查看相对应的mapper中的接口是否添加了@mapper注解且点击其跳转标志确认是否关联

f38f56c2311f436db77d4c871afe92c7.png

2.如果无法跳转,说明其mapper.xml和mapper实例对象路径可能绑定错误,导致的Invalid bound statement

768f2b68d77c4a54aed9c52dcced47e9.png

3.检查 mapper namespace的路径是否和其mapper实例类的路径是否一致

be33f56b886444b7881737ff2ed8bfaa.png

情况二:

application.properties文件问题

mybatis.mapper-locations=classpath:/priv/zhengfa/mapper/*.xml


情况三:

启动类扫描未扫到

@SpringBootApplication
@MapperScan("路径.mapper")
public class Application {
 
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
 
}


情况四:mapper.xml未放到指定的resource文件中,将其移动至其文件即可

b0a82c622acd4ed094e175bd6fa61b7e.png

相关文章
|
Java
springboot3 解决:Could not autowire. No beans of ‘JavaMailSender‘ type found
因为 spring-boot-starter-mail 默认使用某些包发生了变化,在 2.2.xx 版本前后不一,解决对应bug
312 0
springboot之log4j:WARN No appenders could be found for logger
springboot之log4j:WARN No appenders could be found for logger
springboot之log4j:WARN No appenders could be found for logger
|
Java Spring
spring boot Configuration Annotation Proessor not found in classpath(贼简单)
spring boot Configuration Annotation Proessor not found in classpath(贼简单)
|
XML Java 数据库连接
springboot整合mybatis中:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
在项目的启动过程中如果出现:以下报错信息,则可以从以下几个方面入手排查问题。 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper interface和xml文件的定义对应不上,需要检查包名,namespace,函数名称等能否对应上,需要比较细致的对比,这是第二次出现这种异常。我每次都是按照如下方法去逐一排查的,到最后都能解决问题。
681 0
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
idea springboot无法自动装配Could not autowire. No beans of ‘Xxx‘ type found.
|
IDE Java 开发工具
深入Spring Boot:怎样排查expected single matching bean but found 2的异常
写在前面 这个demo来说明怎么排查一个常见的spring expected single matching bean but found 2的异常。
6270 0
SpringBoot项目出现: Invalid bound statement (not found)可能原因
SpringBoot项目出现: Invalid bound statement (not found)可能原因
212 0
SpringBoot项目出现: Invalid bound statement (not found)可能原因
|
Java Spring
SpringBoot中@ConfigurationProperties提示:Configuration Annotation Processor not found in classpath
SpringBoot中@ConfigurationProperties提示:Configuration Annotation Processor not found in classpath
295 0
|
Java 数据库连接 mybatis
springboot 集成mybatis Invalid bound statement (not found)异常
springboot 集成mybatis Invalid bound statement (not found)异常
199 0