使用pagehelper分页 注意版本问题

#spring.security.user.name= sly
#spring.security.user.password= 123456
#spring.security.user.roles= admin
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
spring.datasource.url= jdbc:mysql://192.168.0.221:3307/score1?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password= 123456
spring.datasource.driver-class-name = com.mysql.jdbc.Driver

pagehelper.helperDialect=mysql
pagehelper.params=count=countSql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true

pom文件



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.2.0.RELEASE
         
    
    com.sly
    sly863
    0.0.1-SNAPSHOT
    sly863
    Demo project for Spring Boot

    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
        
            org.springframework.boot
            spring-boot-starter-security
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.2
        
        
            com.alibaba
            druid
            1.1.9
        
        
            mysql
            mysql-connector-java
            runtime
        
        
            com.github.pagehelper
            pagehelper-spring-boot-starter
            1.2.3
        

    

    
        
            
                src/main/java
                
                    **/*.xml
                
            
            
                src/main/resources
            
        
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


controller或者直接在test类中写

@GetMapping("/getUserList")
public Page getUserList(Integer pageNum,Integer pageSize){
    if (pageNum !=null && pageSize!=null){
        PageHelper.startPage(pageNum, pageSize);
        Page  userList= bookMapper.booklist();
        return userList;
    }
    return null;
}

访问url  http://localhost:8080/getUserList?pageNum=1&pageSize=2

或test类中赋值

@Test
public void  getUserList(){
    PageHelper.startPage(1, 2);
    Page bookList= bookMapper.booklist();
    for (Book book:bookList){
        System.out.println(book);
    }
}

 

你可能感兴趣的:(使用pagehelper分页 注意版本问题)