> SpringBoot集成MyBatis分页插件无效
作为一个菜鸟写代码主要靠的就是在网上寻找巨人的肩膀,所以在使用SpringBoot集成MyBatis分页插件是通过网上查询的方法ctrl+c+v完成,结果却发现并不好用,发现依赖等都有添加,继续查询时发现是构建SqlSessionFactory少了些配置
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setDataSource(dataSource());
//指定mapper xml目录
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//MyBatis分页插件
Interceptor[] plugins = new Interceptor[]{new PageHelper()};
factoryBean.setPlugins(plugins);
factoryBean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
return factoryBean.getObject();
}