【已解决】Invalid bound statement (not found)
报错讯息
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.casey.mapper.SysRoleMapper.getUserRoleCode
at org.apache.ibatis.binding.MapperMethod S q l C o m m a n d . < i n i t > ( M a p p e r M e t h o d . j a v a : 235 ) ? [ m y b a t i s ? 3.5.4. j a r : 3.5.4 ] a t c o m . b a o m i d o u . m y b a t i s p l u s . c o r e . o v e r r i d e . M y b a t i s M a p p e r M e t h o d . < i n i t > ( M y b a t i s M a p p e r M e t h o d . j a v a : 50 ) ? [ m y b a t i s ? p l u s ? c o r e ? 3.3.2. j a r : 3.3.2 ] a t c o m . b a o m i d o u . m y b a t i s p l u s . c o r e . o v e r r i d e . M y b a t i s M a p p e r P r o x y . l a m b d a SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.4.jar:3.5.4] at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50) ~[mybatis-plus-core-3.3.2.jar:3.3.2] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda SqlCommand.<init>(MapperMethod.java:235)?[mybatis?3.5.4.jar:3.5.4]atcom.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50)?[mybatis?plus?core?3.3.2.jar:3.3.2]atcom.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambdacachedMapperMethod 0 ( M y b a t i s M a p p e r P r o x y . j a v a : 101 ) ? [ m y b a t i s ? p l u s ? c o r e ? 3.3.2. j a r : 3.3.2 ] a t j a v a . u t i l . c o n c u r r e n t . C o n c u r r e n t H a s h M a p . c o m p u t e I f A b s e n t ( C o n c u r r e n t H a s h M a p . j a v a : 1660 ) ? [ n a : 1.8. 0 2 91 ] a t c o m . b a o m i d o u . m y b a t i s p l u s . c o r e . o v e r r i d e . M y b a t i s M a p p e r P r o x y . c a c h e d M a p p e r M e t h o d ( M y b a t i s M a p p e r P r o x y . j a v a : 100 ) ? [ m y b a t i s ? p l u s ? c o r e ? 3.3.2. j a r : 3.3.2 ] a t c o m . b a o m i d o u . m y b a t i s p l u s . c o r e . o v e r r i d e . M y b a t i s M a p p e r P r o x y . i n v o k e ( M y b a t i s M a p p e r P r o x y . j a v a : 95 ) ? [ m y b a t i s ? p l u s ? c o r e ? 3.3.2. j a r : 3.3.2 ] a t c o m . s u n . p r o x y . 0(MybatisMapperProxy.java:101) ~[mybatis-plus-core-3.3.2.jar:3.3.2] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_291] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:100) ~[mybatis-plus-core-3.3.2.jar:3.3.2] at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:95) ~[mybatis-plus-core-3.3.2.jar:3.3.2] at com.sun.proxy. 0(MybatisMapperProxy.java:101)?[mybatis?plus?core?3.3.2.jar:3.3.2]atjava.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)?[na:1.8.02?91]atcom.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedMapperMethod(MybatisMapperProxy.java:100)?[mybatis?plus?core?3.3.2.jar:3.3.2]atcom.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:95)?[mybatis?plus?core?3.3.2.jar:3.3.2]atcom.sun.proxy.Proxy159.getUserRoleCode(Unknown Source) ~[na:na]
at com.casey.service.impl.SysRoleServiceImpl.isSuperAdmin(SysRoleServiceImpl.java:29) ~[classes/:na]
排查
- namespace 、id 和 文件名均正确
- 配置文件对应目录正确
mybatis-plus:
type-aliases-package: com.casey.domain
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:/mappers/*Mapper.xml
3. 编译后生成的 target 含有 xml 文件
4. maven clean 后,install
5. 重写 xml 文件
======================== 以上都没有用 ===========================
查看 git log,发现这段代码注释后就正常了。
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
//获取mybatis-plus全局配置
GlobalConfig globalConfig = GlobalConfigUtils.defaults();
//mybatis-plus全局配置设置元数据对象处理器为自己实现的那个
globalConfig.setMetaObjectHandler(new AutoFillHandler());
mybatisSqlSessionFactoryBean.setDataSource(dataSource);
//mybatisSqlSessionFactoryBean关联设置全局配置
mybatisSqlSessionFactoryBean.setGlobalConfig(globalConfig);
return mybatisSqlSessionFactoryBean.getObject();
}
猜测是新的 mybatisSqlSession 覆盖了配置文件的 mapper 路径。
添加以下代码
// 设置 Mapper 文件的位置
Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath:mappers/*Mapper.xml");
mybatisSqlSessionFactoryBean.setMapperLocations(resources);
成功解决。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!