mybatis-plus Invalid bound statement (not found) 问题


自己搭一个项目,spring boot+mybatis-plus,引用mybatis-plus  执行发现自己写的sql可以执行,执行basemapper里的方法就会出错,

mybatis-plus Invalid bound statement (not found) 

检查文件(application.yml、mapper.xml等)配置,编译加载是否正确

发现都没什么问题,包加载也替换了几个版本,还是不行,

后面发现需要将mybatis的sqlSessionFactory替换成mybatis-plusd的MybatisSqlSessionFactoryBean

因为是自己写的sqlSessionFactory加载一直也没注意到这个问题,使用默认配置应该也没有这个问题,记录下

  @Bean("sqlSessionFactory")
@Primary
public SqlSessionFactory sqlSessionFactory(@Autowired @Qualifier("dataSource") DataSource dataSource) throws Exception {

MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));

// Interceptor interceptor = new PageInterceptor();
// Properties properties = new Properties();
// properties.setProperty("helperDialect", "sqlserver");
// properties.setProperty("offsetAsPageNum", "true");
// properties.setProperty("rowBoundsWithCount", "true");
// properties.setProperty("reasonable", "false");
// interceptor.setProperties(properties);
// sqlSessionFactoryBean.setPlugins(new Interceptor[] {interceptor});


return sqlSessionFactoryBean.getObject();

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM