Spring 项目中报错提示:Invalid bound statement (not found): com.youshang520i.**.**] with root cause

16 篇文章 1 订阅

报错信息:

2020-09-25 10:23:13.834 ERROR 1539 --- [nio-8008-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.youshang520i.demo.dao.OperationLogMapper.querylist] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.youshang520i.demo.dao.OperationLogMapper.querylist
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.2.jar:3.5.2]
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:49) ~[mybatis-plus-core-3.2.0.jar:3.2.0]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:65) ~[mybatis-plus-core-3.2.0.jar:3.2.0]
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_191]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:65) ~[mybatis-plus-core-3.2.0.jar:3.2.0]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:60) ~[mybatis-plus-core-3.2.0.jar:3.2.0]
	at com.sun.proxy.$Proxy72.querylist(Unknown Source) ~[na:na]
	at com.youshang520i.demo.annotation.service.impl.OperationLogServiceImpl.queryList(OperationLogServiceImpl.java:27) ~[classes/:na]
	at com.youshang520i.demo.annotation.controller.OperationLogController.queryList(OperationLogController.java:42) ~[classes/:na]
	at com.youshang520i.demo.annotation.controller.OperationLogController$$FastClassBySpringCGLIB$$5176f792.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at com.youshang520i.demo.annotation.controller.OperationLogController$$EnhancerBySpringCGLIB$$ec885c72.queryList(<generated>) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.35.jar:9.0.35]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

解决办法:

在application.yml 中添加配置:mybatis-plus. mapper-locations: "classpath:youshang520i/*.xml"

或者

将mapper存放文件的目录和xml文件存放的目录保持一样

会报错:

正确:

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
### 回答1: 这个错误通常出现在 MyBatis ,它表示找不到指定的 SQL 语句。可能的原因是在 MyBatis 的配置文件没有正确地配置 SQL 语句或者 SQL 语句的 ID 拼写错误。请检查 MyBatis 的配置文件和 SQL 语句的 ID 是否匹配,并确保 SQL 语句正确地映射到指定的 Java 方法。另外,也可以检查一下是否存在多个同名的 SQL 语句,这也会导致该错误的出现。 ### 回答2: BindingException: Invalid bound statement (not found): com.huawei.one.service.MachinePartService.getAllDate] with root cause是MyBatis框架的一个异常,意味着未能找到对应的映射语句。 这个异常通常出现在我们使用MyBatis进行数据库操作时,出现没有找到对应的映射语句的情况。可能是因为映射文件的SQL语句有误,或者是映射文件的命名空间、方法名或配置错误。 要解决这个问题,可以按照以下步骤进行排查: 1. 检查映射文件是否存在:确认com.huawei.one.service.MachinePartService.getAllDate的映射文件是否存在,检查文件名和路径是否正确。 2. 检查命名空间是否正确:确认映射文件的命名空间与对应的Java类或接口的全限定名是否一致。 3. 检查方法名是否正确:检查映射文件的方法名是否与接口或Java的方法名一致。 4. 检查SQL语句是否正确: 确认映射文件的SQL语句是否正确,例如表名、列名是否正确,SQL语法是否正确。 5. 检查配置文件:检查MyBatis的配置文件,是否配置了正确的映射文件路径和命名空间。 如果仍然无法解决该异常,可以尝试重新编写或者更新映射文件,确保映射语句正确无误。同时,也可以尝试重新构建项目或重启应用程序,以确保所有配置生效。 总结一下,出现BindingException: Invalid bound statement (not found): com.huawei.one.service.MachinePartService.getAllDate] with root cause异常通常是因为MyBatis无法找到对应的映射语句。通过检查映射文件、命名空间、方法名和SQL语句等方面的配置,可以解决此问题。 ### 回答3: BindingException: Invalid bound statement (not found): com.huawei.one.service.MachinePartService.getAllDate] with root cause 是MyBatis在执行SQL语句时发生的异常。通常情况下,这个异常是由于没有找到指定的SQL语句引起的。 在这个异常信息Invalid bound statement表示绑定的SQL语句无效,而后面的(com.huawei.one.service.MachinePartService.getAllDate] with root cause)是具体的错误原因。 这个异常通常有以下几种可能的原因: 1. SQL语句没有正确配置或者不存在:检查代码的SQL配置文件或者注解,确认SQL语句的命名是否正确,并且确保SQL语句的存在。 2. Mapper文件(或接口)没有正确配置或者没有正确的命名空间:检查Mapper文件(或者接口)是否正确配置了namespace,且namespace与SQL语句绑定的接口或者类的完整类名一致。 3. 数据库连接配置错误:如果数据库连接配置错误,可能导致MyBatis无法正确解析SQL语句。检查数据库连接配置是否正确,并且确认数据库是否正常运行。 综上所述,当发生BindingException: Invalid bound statement (not found): com.huawei.one.service.MachinePartService.getAllDate] with root cause时,我们需要检查MyBatis的SQL配置和Mapper文件(或接口)是否正确,并且确认数据库连接是否正常。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值