1.背景
老项目之前是mybatis的,但是后来想使用mybatis-plus的功能,
故需要将mybatis升级为mybatis-plus项目
2.报错
报错原因很简单就是找报道Mapper
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.XXX.mapper.IOrderDeliveryMapper.updateOrderMain
3.解决方案
不要使用springboot自己封装的SqlSessionFactoryBean,而是自己写一个配置文件封装代码如下
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
String mapperLocations = "classpath:mapper/*.xml";
VFS.addImplClass(SpringBootVFS.class);
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
return sessionFactory.getObject();
}