Search in sources :

Example 1 with PageHelper

use of com.github.pagehelper.PageHelper in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with PageHelper

use of com.github.pagehelper.PageHelper in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with PageHelper

use of com.github.pagehelper.PageHelper in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with PageHelper

use of com.github.pagehelper.PageHelper in project jim-framework by jiangmin168168.

the class MyBatisConfig method sqlSessionFactoryBean.

@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactoryBean() {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage("com.jim.dao.generated.entity");
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("dialect", "postgresql");
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    try {
        bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
        return bean.getObject();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with PageHelper

use of com.github.pagehelper.PageHelper in project new-cloud by xie-summer.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(MybatisConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    pageHelper.setProperties(properties);
    /**
     *abel533通用mapper
     */
    // MapperInterceptor mapperInterceptor = new MapperInterceptor();
    // Properties props = new Properties();
    // /**--主键自增回写方法,默认值MYSQL,详细说明请看文档 -->*/
    // props.setProperty("IDENTITY","MYSQL");
    // /**<!--通用Mapper接口,多个通用接口用逗号隔开 -->*/
    // props.setProperty("mappers", "com.github.abel533.mapper.IMapper");
    // mapperInterceptor.setProperties(props);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // bean.setPlugins(new Interceptor[]{mapperInterceptor});
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/**.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

PageHelper (com.github.pagehelper.PageHelper)12 Properties (java.util.Properties)12 Bean (org.springframework.context.annotation.Bean)12 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)11 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)11 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)9 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)1 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1