Detailed explanation of mybatis using PageHelper plug-in
                                        
                    •
                    Java                                    
                This article mainly introduces the detailed process of mybatis using PageHelper plug-in. The example code is introduced in great detail, which has certain reference value for everyone's study or work. Friends in need can refer to it
1. Add plug-in dependencies
<dependency> <groupId>com.github.pageHelper</groupId> <artifactId>pageHelper</artifactId> <version>5.0.4</version> </dependency> <dependency> <groupId>com.github.pageHelper</groupId> <artifactId>pageHelper-spring-boot-autoconfigure</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>com.github.pageHelper</groupId> <artifactId>pageHelper-spring-boot-starter</artifactId> <version>1.2.5</version> </dependency>
2. Add profile
pageHelper.helper-dialect=MysqL pageHelper.params=count=countsql pageHelper.reasonable=true pageHelper.support-methods-arguments=true
3. Create a new test class
@GetMapping("/list")
@ResponseBody
public PageInfo<User>getUserList(){
//分页起始也页数和条数
 pageHelper.startPage(0,5);
//调用查询方法,此时的查询方法已经是分页返回的数据
 List<User> list=userService.selectAll();
//封装分页参数返回给前台
PageInfo pageInfo = new PageInfo(list);
return pageInfo;
}
If it fails, you can add AOP dependency in POM
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency>
The above is the whole content of this article. I hope it will help you in your study, and I hope you will support us a lot.
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        