我用的若依框架,将mybatis改为mybatis-plus
在重启项目时报错Invalid bound statement (not found)
百思不得其解,百度回答各种mapper、xml配置路径啥的,但是springboot项目需要配置一个扫描mapper包地址,看了一下代码扫描包的地址配置没有问题,
发现配置了一个SqlSessionFactory,用的是SqlSessionFactoryBean,之前好像其它项目有遇到过这个问题,需要给SqlSessionFactoryBean换成MybatisSqlSessionFactoryBean即可,于是替换
原代码:
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
return bean.getObject();
更换后代码:
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource);
return bean.getObject();
再次启动项目即可正常运行,检查项目sql执行情况也是正常执行