<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.4</version>
</dependency>
主要是指定mapper.xml的位置
mybatis:
mapper-locations: classpath*:/mapper/*Mapper.xml
type-aliases-package: com.csg.spider.bean
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
map-underscore-to-camel-case: true
cache-enabled: false
jdbc-type-for-null: null
Pagehelper使用默认配置
@MapperScan(basePackages = {"com.csg.spider.dao"})
service层次
public List getPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum,pageSize,false,false,true);
List all = spiderDao.getAll();
return toVos(all);
}
Dao层
List getAll();
Mybatis的xml
<select id="getAll" resultType="com.csg.spider.bean.Spider">
select * from spider
</select>