springboot中继承MongoRepository方式如何分页
解决方法:
1.dao的方法
public interface TaskDoWithDesignerDao extends MongoRepository<TaskDoWithDesigner,String> {
List<TaskDoWithDesigner>findAllByDesignerId(Long designerId,Pageable pageable);
}
2.查询第一页,每页10条,以_id为倒序来分页
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
taskDoWithDesignerDao.findAllByDesignerId(userId,new PageRequest(0, 10, Sort.Direction.DESC, "_id"));