当前位置: 首页 > news >正文

“openfeign“ 报错Invalid bound statement (not found)

报错信息

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.liu.bus.feign.UserSrvFeignClient.findUserByUserIdat org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227) ~[mybatis-3.4.6.jar:3.4.6]at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49) ~[mybatis-3.4.6.jar:3.4.6]at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65) ~[mybatis-3.4.6.jar:3.4.6]at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58) ~[mybatis-3.4.6.jar:3.4.6]at com.sun.proxy.$Proxy85.findUserByUserId(Unknown Source) ~[na:na]at com.wut.service.ContentService.findShareContent(ContentService.java:35) ~[classes/:na]at com.wut.controller.ContentController.getShareContent(ContentController.java:18) ~[classes/:na]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.8.RELEASE.jar:5.2.8.RELEASE]at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.37.jar:4.0.FR]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.8.RELEASE.jar:5.2.8.RELEASE]at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]

问题背景
springcloud整合openfeign,两个服务之间的远程调用。正常启动服务,访问测试接口时,总是报错:
org.apache.ibatis.binding.BindingException Invalid bound statement (not found): com.liu.bus.feign.SignClient.queryStatus

这个错误通常出现在OpenFeign与MyBatis集成场景中,以下是综合解决方案:

原因及解决方案

  1. Mapper扫描冲突问题
  • @MapperScan("com.liu.bus") 扫描的包下既有mybatis的映射包,又包含了openfeign调用的映射包,而openfeign调用的映射包中,方法有多个参数,参数上没有添加@Param注解,导致调用时报了上术错误。

  • 检查服务间是否存在相同包名的@MapperScan配置,若两个服务都扫描了com.yw.bus包会导致映射冲突

解决方法
对mybatis的映射包路径精确到类的包名。

建议为每个服务指定精确的Mapper包路径,例如:

@MapperScan("com.liu.bus.mapper") // 被调用方

com.liu.bus.provider.mapper为mybatis映射包的路径。

这样再调用openfeign时就不会产生扫描冲突了。

http://www.dtcms.com/a/335138.html

相关文章:

  • windows开机启动软件
  • 低空经济产业链全景解析
  • ISIS区域内、区域间计算
  • 发文暴论!线性注意力is all you need!
  • Windows 操作系统 - Windows 恢复浏览器标题栏颜色
  • VS Code配置MinGW64编译Ipopt库
  • 什么是微前端?
  • 关键点检测(11)-HRNet网络
  • 博士招生 | 香港大学 机器增强认知实验室 招收博士生/实习生/访问学生
  • bilibili视频总结
  • mysql使用group by的时候想显示没有参与聚合的字段怎么办
  • 【开发技巧】VS2022+QT5+OpenCV4.10开发环境搭建QT Creator
  • Geostudio 2018 R2安装后提示:软件不能在虚拟机上运行
  • 关于 Linux 内存管理
  • MySQL 深分页优化与条件分页:把 OFFSET 换成“游标”,再用覆盖索引抄近路
  • WSL 配置文件 wsl.conf 设置
  • IOMMU的2级地址翻译机制及多级(2~5)页表查找
  • 56. 合并区间
  • 计算你的身体质量指数(BMI)
  • SQL183 近三个月未完成试卷数为0的用户完成情况
  • ​江湖四大秘本之一的《英耀篇》​
  • 片料矫平机科普
  • Spring AI架构分析
  • leetcode-139. 单词拆分-C
  • 每日任务day0816:小小勇者成长记之符文羊皮卷
  • Java -- 泛型-自定义泛型
  • 【数据结构入门】二叉树(2)
  • 数据结构 实现循环队列的三种方法
  • 模式组合应用-桥接模式(一)
  • (论文速读)ViDAR:视觉自动驾驶预训练框架