Spring-boot collection MyBatis GitHub paging query
One, the dependency package
<!--MySQL database driver. -<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java< /artifactid> </dependency> <!--Spring-Boot MyBatis dependency: Please do not use 1.0. 0 version, because the Interceptor plugin is not yet supported,1.1. 1 You can use the latest version-<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactid>mybati S-spring-boot-starter</artifactid> <version>1.1.1</version> </dependency> <!--Paging MyBatis provides an interceptor interface that allows us to implement our own interceptors and load them into sqlsessionfactory as a plugin. -<!--paging-<dependency> <groupId>com.github.pagehelper</groupId> < Artifactid>pagehelper</artifactid> <version>4.1.0</version> </dependency>
Second, join Pagehelper
@Configuration Public classmybatisconfiguration {@Bean Publicpagehelper Pagehelper () {System.out.println ("Mybatisconfiguration.pagehelper ()"); Pagehelper Pagehelper=NewPagehelper (); Properties P=NewProperties (); P.setproperty ("Offsetaspagenum", "true"); P.setproperty ("Rowboundswithcount", "true"); P.setproperty ("Reasonable", "true"); Pagehelper.setproperties (P); returnPagehelper; }}
Three
@SpringBootApplication@MapperScan ("com.fjm.*") // scan files in this directory Public class App { publicstaticvoid main (string[] args) { Springapplication.run (App.class, args);} }
Iv. adding Pagehelper to the Controller query method
Public List<user> Find (map map) { // Add paged query condition pagehelper.startpage (0, 2) ; return userservice.find (null); }
Spring-boot Collection MyBatis Paged Query