错误描述:在springboot整合mybatis多数据源配置时碰到,无效的绑定状态错误,即为mapper接口与mapper.xml绑定无效。详细报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.yuhua.springbootmybatisplus.system.mapper.StudentMapper.selectList
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod$SqlCommand.<init>(MybatisMapperMethod.java:242) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:54) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedMapperMethod$0(MybatisMapperProxy.java:65) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_73]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:65) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:60) ~[mybatis-plus-core-3.1.0.jar:3.1.0]
at com.sun.proxy.$Proxy65.selectList(Unknown Source) ~[na:na]
...
问题原因:根本原因是mapper与mapper.xml相互找不的问题,目前作者遇到情况是xml文件实际路径与xml文件配置扫描路径不一致问题。
xml文件扫描路径的配置:
# xml 扫描路径
mapper-locations: classpath:mapper/*/*.xml
文件的实际位置:
处理方法:修改xml文件扫描路径,或者将xml文件移至配置扫描路径下。