com.github.pagehelper.PageHelper.setProperties()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(267)

本文整理了Java中com.github.pagehelper.PageHelper.setProperties()方法的一些代码示例,展示了PageHelper.setProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PageHelper.setProperties()方法的具体详情如下:
包路径:com.github.pagehelper.PageHelper
类名称:PageHelper
方法名:setProperties

PageHelper.setProperties介绍

暂无

代码示例

代码示例来源:origin: lihengming/spring-boot-api-project-seed

  1. @Bean
  2. public SqlSessionFactory sqlSessionFactoryBean(DataSource dataSource) throws Exception {
  3. SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
  4. factory.setDataSource(dataSource);
  5. factory.setTypeAliasesPackage(MODEL_PACKAGE);
  6. //配置分页插件,详情请查阅官方文档
  7. PageHelper pageHelper = new PageHelper();
  8. Properties properties = new Properties();
  9. properties.setProperty("pageSizeZero", "true");//分页尺寸为0时查询所有纪录不再执行分页
  10. properties.setProperty("reasonable", "true");//页码<=0 查询第一页,页码>=总页数查询最后一页
  11. properties.setProperty("supportMethodsArguments", "true");//支持通过 Mapper 接口参数来传递分页参数
  12. pageHelper.setProperties(properties);
  13. //添加插件
  14. factory.setPlugins(new Interceptor[]{pageHelper});
  15. //添加XML目录
  16. ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  17. factory.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
  18. return factory.getObject();
  19. }

代码示例来源:origin: jmdhappy/xxpay-master

  1. @Bean
  2. public SqlSessionFactory sqlSessionFactory() throws Exception {
  3. SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  4. sqlSessionFactoryBean.setDataSource(dataSource());
  5. //mybatis分页
  6. PageHelper pageHelper = new PageHelper();
  7. Properties props = new Properties();
  8. props.setProperty("dialect", "mysql");
  9. props.setProperty("reasonable", "true");
  10. props.setProperty("supportMethodsArguments", "true");
  11. props.setProperty("returnPageInfo", "check");
  12. props.setProperty("params", "count=countSql");
  13. pageHelper.setProperties(props); //添加插件
  14. sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  15. PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  16. sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/shop/dao/mapper/*.xml"));
  17. return sqlSessionFactoryBean.getObject();
  18. }

代码示例来源:origin: jmdhappy/xxpay-master

  1. @Bean
  2. public SqlSessionFactory sqlSessionFactory() throws Exception {
  3. SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  4. sqlSessionFactoryBean.setDataSource(dataSource());
  5. //mybatis分页
  6. PageHelper pageHelper = new PageHelper();
  7. Properties props = new Properties();
  8. props.setProperty("dialect", "mysql");
  9. props.setProperty("reasonable", "true");
  10. props.setProperty("supportMethodsArguments", "true");
  11. props.setProperty("returnPageInfo", "check");
  12. props.setProperty("params", "count=countSql");
  13. pageHelper.setProperties(props); //添加插件
  14. sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  15. PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  16. sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/dal/dao/mapper/*.xml"));
  17. return sqlSessionFactoryBean.getObject();
  18. }

代码示例来源:origin: mrdear/JavaWEB

  1. properties.setProperty("returnPageInfo", "check");
  2. properties.setProperty("params", "count=countSql");
  3. pageHelper.setProperties(properties);

代码示例来源:origin: xuyaohui/cloud-ida-cli

  1. @Bean
  2. public PageHelper pageHelper() {
  3. PageHelper pageHelper = new PageHelper();
  4. Properties p = new Properties();
  5. p.setProperty("reasonable", "true");
  6. pageHelper.setProperties(p);
  7. return pageHelper;
  8. }
  9. }

代码示例来源:origin: admin801122/springboot2-spring5-studying

  1. private PageHelper pagePlugin() {
  2. PageHelper pageHelper = new PageHelper();
  3. Properties properties = new Properties();
  4. properties.setProperty("reasonable", "true");
  5. properties.setProperty("supportMethodsArguments", "true");
  6. properties.setProperty("returnPageInfo", "check");
  7. properties.setProperty("params", "count=countSql");
  8. pageHelper.setProperties(properties);
  9. return pageHelper;
  10. }

代码示例来源:origin: wp771910012/Lottery

  1. @Bean
  2. public Interceptor pageHelper(){
  3. //分页插件
  4. PageHelper pageHelper = new PageHelper();
  5. Properties properties = new Properties();
  6. properties.setProperty("reasonable", "false");
  7. properties.setProperty("supportMethodsArguments", "true");
  8. properties.setProperty("returnPageInfo", "check");
  9. properties.setProperty("params", "count=countSql");
  10. pageHelper.setProperties(properties);
  11. return pageHelper;
  12. }
  13. @Bean

代码示例来源:origin: souyunku/SpringBootExamples

  1. private SqlSessionFactory createSqlSessionFactory(DataSource dataSource, String mapperLocations) throws Exception {
  2. SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  3. sqlSessionFactoryBean.setDataSource(dataSource);
  4. // mybatis分页
  5. PageHelper pageHelper = new PageHelper();
  6. Properties props = new Properties();
  7. props.setProperty("dialect", "mysql");
  8. props.setProperty("reasonable", "true");
  9. props.setProperty("supportMethodsArguments", "true");
  10. props.setProperty("returnPageInfo", "check");
  11. props.setProperty("params", "count=countSql");
  12. pageHelper.setProperties(props); // 添加插件
  13. sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  14. PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  15. sqlSessionFactoryBean.setMapperLocations(resolver.getResources(mapperLocations));
  16. return sqlSessionFactoryBean.getObject();
  17. }
  18. }

代码示例来源:origin: souyunku/Picture-Bed

  1. private SqlSessionFactory createSqlSessionFactory(DataSource dataSource, String mapperLocations) throws Exception {
  2. SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  3. sqlSessionFactoryBean.setDataSource(dataSource);
  4. // mybatis分页
  5. PageHelper pageHelper = new PageHelper();
  6. Properties props = new Properties();
  7. props.setProperty("dialect", "mysql");
  8. props.setProperty("reasonable", "true");
  9. props.setProperty("supportMethodsArguments", "true");
  10. props.setProperty("returnPageInfo", "check");
  11. props.setProperty("params", "count=countSql");
  12. pageHelper.setProperties(props); // 添加插件
  13. sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  14. PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  15. sqlSessionFactoryBean.setMapperLocations(resolver.getResources(mapperLocations));
  16. return sqlSessionFactoryBean.getObject();
  17. }
  18. }

代码示例来源:origin: liutao910612/TOOL_CAS

  1. @Bean
  2. public SqlSessionFactory sqlSessionFactory() throws Exception {
  3. SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  4. sqlSessionFactoryBean.setDataSource(dataSource);
  5. PageHelper pageHelper = new PageHelper();
  6. Properties props = new Properties();
  7. //启用合理化后,如果pageNumM<1会查询第一页,如果pageNum>pages会查询最后一页
  8. props.setProperty("reasonable", "true");
  9. //支持通过Mapper接口参数来传递分页参数
  10. props.setProperty("supportMethodsArguments", "true");
  11. props.setProperty("returnPageInfo", "check");
  12. props.setProperty("params", "count=countSql");
  13. //添加插件
  14. pageHelper.setProperties(props);
  15. sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
  16. PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  17. sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPER_LOCATION));
  18. return sqlSessionFactoryBean.getObject();
  19. }
  20. @Bean public PlatformTransactionManager transactionManager() throws SQLException {

代码示例来源:origin: YHYR/Mybatis

  1. @Bean(name = "sqlSessionFactory")
  2. @Primary
  3. public SqlSessionFactory sqlSessionFactoryBean() {
  4. SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
  5. bean.setDataSource(dataSource);
  6. bean.setTypeAliasesPackage("com.yhyr.mybatis.domain");
  7. // 分页插件
  8. PageHelper pageHelper = new PageHelper();
  9. Properties properties = new Properties();
  10. properties.setProperty("reasonable", "true");
  11. properties.setProperty("supportMethodsArguments", "true");
  12. properties.setProperty("returnPageInfo", "check");
  13. properties.setProperty("params", "count=countSql");
  14. pageHelper.setProperties(properties);
  15. // 添加插件
  16. bean.setPlugins(new Interceptor[] {pageHelper});
  17. // 添加XML目录
  18. ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  19. try {
  20. bean.setMapperLocations(resolver.getResources("classpath*:mapper/*.xml"));
  21. return bean.getObject();
  22. } catch (Exception e) {
  23. throw new RuntimeException(e);
  24. }
  25. }

代码示例来源:origin: com.gitee.sunlu/zm-cloud-dao

  1. @Bean(name = "sqlSessionFactory")
  2. public SqlSessionFactory sqlSessionFactoryBean() {
  3. SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
  4. bean.setDataSource(dataSource);
  5. bean.setTypeAliasesPackage("com.zm.business.model");
  6. //分页插件
  7. PageHelper pageHelper = new PageHelper();
  8. Properties properties = new Properties();
  9. properties.setProperty("reasonable", "true");
  10. properties.setProperty("supportMethodsArguments", "true");
  11. properties.setProperty("returnPageInfo", "check");
  12. properties.setProperty("params", "count=countSql");
  13. pageHelper.setProperties(properties);
  14. //添加插件
  15. bean.setPlugins(new Interceptor[]{pageHelper});
  16. //添加XML目录
  17. ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  18. try {
  19. bean.setMapperLocations(resolver.getResources("classpath*:mapper/*.xml"));
  20. // 设置过滤_
  21. org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
  22. configuration.setMapUnderscoreToCamelCase(true);
  23. bean.setConfiguration(configuration);
  24. return bean.getObject();
  25. } catch (Exception e) {
  26. e.printStackTrace();
  27. throw new RuntimeException(e);
  28. }
  29. }

相关文章