【发布时间】:2020-03-22 10:40:36
【问题描述】:
我想使用带有默认排序方向的 Spring Data JPA 和最新的 spring-boot-starter-parent 2.2.1.RELEASE:
@Override
public Page<ProcessingLogs> findAll(int page, int size) {
return dao.findAll(PageRequest.of(page,size, new Sort(Sort.Direction.DESC, "createdAt")));
}
但我得到错误:
The constructor Sort(Sort.Direction, String) is undefined
你知道我该如何解决这个问题吗?
【问题讨论】:
-
你链接了源代码,你有没有看一下?
Sort.by(Sort.Direction.DESC, "createdAt");. -
...我要把
new Sort改成Sort.by
标签: java spring spring-boot spring-data-jpa spring-data