use of com.github.pagehelper.PageHelper in project spring-boot-api-seed-project by selfassu.
the class MybatisConfigurer method sqlSessionFactoryBean.
@Bean(name = "sqlSessionFactoryBean")
public SqlSessionFactory sqlSessionFactoryBean(@Qualifier("dataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/mapper/*Mapper.xml"));
// 给 model 设置别名
sqlSessionFactoryBean.setTypeAliasesPackage(ProjectConstants.BASE_TARGET_PACKAGE + ProjectConstants.MODEL_PACKAGE_SUFFIX);
PageHelper pageHelper = new PageHelper();
Properties properties = new Properties();
properties.setProperty("pageSizeZero", "true");
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
pageHelper.setProperties(properties);
// 设置分页插件 TODO 这里有问题
sqlSessionFactoryBean.setPlugins(new Interceptor[] { (Interceptor) pageHelper });
return sqlSessionFactoryBean.getObject();
}
use of com.github.pagehelper.PageHelper in project CBEC-B2B by A-Cubic.
the class DataSourceConfig method sqlSessionFactoryBean.
@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
// mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "false");
// props.setProperty("returnPageInfo", "check");
// props.setProperty("params", "count=countSql");
pageHelper.setProperties(props);
// 添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[] { pageHelper });
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
return sqlSessionFactoryBean.getObject();
}
Aggregations