mybatis错误: Invalid bound statement (not found) 怎么解决
来源:互联网 发布:snmptrap协议端口号 编辑:程序博客网 时间:2024/05/29 10:23
在网上找了很多方法都没得到解决,由于我是同时采用的注解和xml的方法来配置mybatis的mapper…测试xml对应的mapper接口的方法就失败,单独用注解的方式就能测试成功,后来发现坑爹的是由于mapper接口和mapper.xml文件不在一个包里!!!由于我用的generator自动生成的dao类,默认就给我分到两个包去了,希望以后遇到这个问题的童鞋注意哦哦哦.
2017.8.15更新:
本人是使用java配置来配置Spring的,也就是ContextLoaderListener也是基于java配置的.在SqlSessionFactoryBean中,就要用如下代码手动设置*mapper.xml文件位置,同时使用@mapperScan注解扫描dao类的位置,不然也会报错,其实就是xml配置的替代版 .如下所示:
package cn.paul.config;import com.mchange.v2.c3p0.ComboPooledDataSource;import org.mybatis.spring.SqlSessionFactoryBean;import org.mybatis.spring.annotation.MapperScan;import org.springframework.context.annotation.*;import org.springframework.core.io.Resource;import org.springframework.core.io.support.PathMatchingResourcePatternResolver;import org.springframework.jdbc.datasource.DataSourceTransactionManager;import org.springframework.web.servlet.config.annotation.EnableWebMvc;import javax.sql.DataSource;/** * Created by paul on 2017-06-14. */@ComponentScan(basePackages = "cn.paul.*", excludeFilters = {@ComponentScan.Filter (type = FilterType.ANNOTATION, classes = EnableWebMvc.class)})@Configuration@MapperScan({"cn.paul.dao","mapper"})@ImportResource("classpath:spring-shiro-web.xml")public class RootConfig { @Bean public DataSource dataSource() { return new ComboPooledDataSource(); } @Bean public SqlSessionFactoryBean sqlSessionFactory() throws Exception { SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); sqlSessionFactory.setDataSource(dataSource()); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sqlSessionFactory.setMapperLocations(new Resource[]{ resolver.getResource("classpath:mapper/UserMapper.xml"), resolver.getResource("classpath:mapper/RoleMapper.xml"), resolver.getResource("classpath:mapper/PermissionMapper.xml") }); return sqlSessionFactory; } @Bean public DataSourceTransactionManager dataSourceTransactionManager() { return new DataSourceTransactionManager(dataSource()); }}
阅读全文
0 0
- mybatis错误: Invalid bound statement (not found) 怎么解决
- maven + mybatis Invalid bound statement (not found) 错误解决
- mybatis错误: Invalid bound statement (not found)
- mybatis错误:Invalid bound statement (not found)
- mybatis错误:Invalid bound statement (not found)
- mybatis错误:Invalid bound statement (not found)
- mybatis错误 Invalid bound statement (not found)
- [MyBatis]Invalid bound statement (not found)错误
- mybatis错误:Invalid bound statement (not found)
- MyBatis Invalid bound statement (not found)错误
- mybatis错误:Invalid bound statement (not found)
- mybatis错误:Invalid bound statement (not found)
- MyBatis绑定错误:Invalid bound statement (not found)
- [MyBatis]诡异的Invalid bound statement (not found)错误
- MyBatis 诡异的Invalid bound statement (not found)错误
- Mybatis - 在idea中错误:Invalid bound statement (not found)
- Mybatis框架的错误:Invalid bound statement not found
- Mybatis在idea中错误:Invalid bound statement (not found)
- 数组相关
- 【luogu1471】方差(线段树)
- Qt Creator 中使用 Git / Github
- 7.7欢乐爆零赛[hao][kun][nan]
- WinFrom验证码的实现
- mybatis错误: Invalid bound statement (not found) 怎么解决
- 工具类【Http请求】
- JavaScript从url中获取参数 / js get url parameter
- python学习4——元组
- python元组,集合
- linux驱动注册过程分析--driver_register(一)
- Linux命令一:sudo
- H5 中监听页面滚动事件,判断滚动方向的方法
- Memcached使用