spring boot mybatis分页插件的使用

1、配置poom.xml文件

        
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>

        
        <dependency>
            <groupId>org.mybatis.spring.bootgroupId>
            <artifactId>mybatis-spring-boot-starterartifactId>
            <version>1.3.0version>
        dependency>

         
        <dependency>
            <groupId>com.github.pagehelpergroupId>
            <artifactId>pagehelper-spring-boot-starterartifactId>
            <version>1.1.1version>
        dependency>

2、service层代码

    @Override
    public String getUsers(Integer page, Integer rows) {
        List<User> list = userMapper.selectByExample(null);
        PageHelper.startPage(page, rows);
        PageInfo<User> pageInfo = new PageInfo<User>(list);
        return pageInfo.toString();
    }

你可能感兴趣的:(Spring,Boot)