xml配置PageHepler

添加maven依赖
    <dependency>
      <groupId>com.github.pagehelper</groupId>
      <artifactId>pagehelper</artifactId>
      <version>3.4.2-fix</version>
    </dependency>

  


mybatisConfig.xml添加配置
<!-- 配置分页插件 -->
	<plugins>
		<plugin interceptor="com.github.pagehelper.PageHelper">
			<!-- 配置数据库的方言 -->
			<!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->        
        	<property name="dialect" value="mysql"/>
		</plugin>

	</plugins>

 使用

public List<User> list(Integer num){
    PageHelper.startPage(1,num);//开启分页功能,会在拦截器链中添加分页功能的拦截器
    return this.userMapper.selectAll();
}

  

posted @ 2020-09-14 18:40  梦幻修罗  阅读(244)  评论(0)    收藏  举报