1, if the project is Maven build, it is very convenient, PageHelper first introduced package dependencies:
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>4.1.6</version> </dependency>
If not Maven project, it is necessary to introduce PageHelper jar package to the project.
2, MyBatis configuration file to configure:
< Plugins > <-! Com.github.pagehelper to PageHelper class where the package name -> < plugin Interceptor = "com.github.pagehelper.PageHelper" > <-! Set database type Oracle, Mysql, MariaDB, SQLite, Hsqldb, PostgreSQL database six kinds -> < Property name = "dialect" value = "MySQL" /> </ plugin > </ plugins >
3, using plug-ins:
// preceding code database query is performed by adding the following statement PageHelper.startPage (pageNum, the pageSize); List <Hospital> hospitalList = hospitalService.findList (Hospital);
4, configuration is complete, start the test.
From the micro-channel public number: Programming Society
Advanced programmers daily book, please pay attention!