构造函数 Sort(Sort.Direction, String) 未定义 [英] The constructor Sort(Sort.Direction, String) is undefined

查看:55
本文介绍了构造函数 Sort(Sort.Direction, String) 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在最新的 spring-boot-starter-parent 2.2.1.RELEASE 中使用带有默认排序方向的 Spring Data JPA:

I want to use Spring Data JPA with default sort direction with the latest 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

这是最新的代码:https://github.com/spring-projects/spring-data-commons/blob/master/src/main/java/org/springframework/data/domain/Sort.java

你知道我该如何解决这个问题吗?

Do you know how I can solve this issue?

推荐答案

像这样使用 PageRequest.of(page, size, Sort.by(Sort.Direction.DESC,"createdAt"))

这篇关于构造函数 Sort(Sort.Direction, String) 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆