当前位置:网站首页>启动报错:Caused by: org.apache.ibatis.binding.BindingException汇总解决
启动报错:Caused by: org.apache.ibatis.binding.BindingException汇总解决
2022-08-09 14:49:00 【三省同学】
报错
Springboot启动时从nacos拉取配置。启动报错:
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): xxx
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
at com.sun.proxy.$Proxy143.selectConfigList(Unknown Source)
at com.mmoa.system.service.impl.SysConfigServiceImpl.init(SysConfigServiceImpl.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)
... 32 common frames omitted
报错分析
通常出现错误Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found),都有如下原因
1.mapper.xml未扫描注册
# mybatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.xx.xx
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath:mapper/**/*.xml
2.mapper接口与mapper.xml不在同一个包(package)下或文件名不一致
3.mapper.xml的命名空间(namespace)与mapper接口的包名不一致
4. 接口的方法名,与xml中的sql标签的id不一致
5.接口中的返回值与xml方法配置esultMap或resultType不一致
通过,排查几种可能得到情况,均为发现问题,由于是通过nacos拉取配置有可能是配置未拉取到。
仔细查看启动信息。
15:43:15.030 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,87] - Ignore the empty nacos configuration and get it based on dataId[application-master.yml] & group[DEFAULT_GROUP]
15:43:15.037 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,87] - Ignore the empty nacos configuration and get it based on dataId[test] & group[DEFAULT_GROUP]
15:43:15.043 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,87] - Ignore the empty nacos configuration and get it based on dataId[test.yml] & group[DEFAULT_GROUP]
15:43:15.047 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,87] - Ignore the empty nacos configuration and get it based on dataId[test-master.yml] & group[DEFAULT_GROUP]
15:43:15.052 [main] INFO c.m.s.MmoaSystemApplication - [logStartupProfileInfo,674] - The following profiles are active: master
发现nacos轮训三个配置都未获取到,猜测正确
注:
拉取Nacos的配置文件时会轮训三个dataID:
格式一:name
文件名:xxx_config;
格式二:name.yaml
文件名+yaml后缀;格式三:name-master.yaml
文件名+profile + 后缀。中间用“-”分割。
解决
环境配置错误,修改环境重启服务成功。
# Spring
spring:
application:
# 应用名称
name: test
profiles:
# 环境配置
active: dev
小结
若未改动代码,启动报错,先检查配置环境是否正确或尝试清楚缓存等操作。

我与春风皆过客,你携秋水揽星河。
边栏推荐
- my creative day
- DMPE-PEG-Mal Maleimide-PEG-DMPE 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
- MySQL 原理与优化:Limit 查询优化
- leetcode 剑指 Offer 17. 打印从1到最大的n位数
- C语言程序设计笔记(浙大翁恺版) 第二周:计算
- Zero Time Technology | Nomad cross-chain bridge theft of 180 million US dollars incident analysis
- 易基因|作物育种:DNA甲基化在大豆优良品种培育中的作用研究成果
- 【DevOps】jekins部署(一)
- leetcode 剑指 Offer 07. 重建二叉树
- Common sql records
猜你喜欢

Use Baidu EasyDL to realize intelligent identification of health code/travel code in 30 minutes

Anaconda3安装后无法启动,启动闪退 2020-9

【磁场建模项目2020-02-Lilin】采集板硬件规范

Zero Time Technology | Nomad cross-chain bridge theft of 180 million US dollars incident analysis

C语言程序设计笔记(浙大翁恺版) 第十二周:程序结构

【软考】2022年上半年软考过啦

Unity Obi插件修改到支持URP

参考文献格式

Fiddler弱网测试

SMI 与 Gateway API 的 GAMMA 倡议意味着什么?
随机推荐
概率论基础知识整理 | 随机变量的数字特征
道路形态(道路要素)
浏览器tab页签上的title图标favicon.icon
基于微信云开发的幼儿园招生报名小程序
C语言——指针和数组、指针数组和数组指针、指针和二维数组
【Serilog】具有完全结构化事件的简单.NET日志记录
Use Baidu EasyDL to realize intelligent identification of health code/travel code in 30 minutes
刷完这174道Android开发面试题,搞懂所有技术栈
STSW-LINK00x下载集合,百度云连接
【软考】2022年上半年软考过啦
【最新】【获取ip】获取本地ip 获取本机ip地址
【消息中心】架构准备
firewall防火墙详解
从零开始Blazor Server(9)--修改Layout
The rising star DPU is revolutionizing the data center!
DSPE-PEG-Hydrazide,DSPE-PEG-HZ,磷脂-聚乙二醇-酰肼MW:1000
网站授权QQ登录
C语言程序设计笔记(浙大翁恺版) 第三周:判断
Shell编程之循环语句
相似图像的检测方法