Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Mongo模板从MongoDB中按降序提取数据时出错_Java_Spring_Mongodb_Amazon Web Services_Spring Data - Fatal编程技术网

Java 使用Mongo模板从MongoDB中按降序提取数据时出错

Java 使用Mongo模板从MongoDB中按降序提取数据时出错,java,spring,mongodb,amazon-web-services,spring-data,Java,Spring,Mongodb,Amazon Web Services,Spring Data,我试图使用MongoTemplate以页面格式从MongoDB获取数据,并按降序对其进行排序,但在提到排序顺序时遇到错误。我的代码如下: @Autowired private MongoTemplate template; Query query = new Query(); Pageable pageable = PageRequest.of(request.getOffset(),request.getLimit(),Sort.by(Sort.Direction.DESC,"la

我试图使用MongoTemplate以页面格式从MongoDB获取数据,并按降序对其进行排序,但在提到排序顺序时遇到错误。我的代码如下:

@Autowired
private MongoTemplate template;

Query query = new Query();
Pageable pageable = PageRequest.of(request.getOffset(),request.getLimit(),Sort.by(Sort.Direction.DESC,"lastUpdatedAt"));
List<Student> list = template.find(query.with(pageable), Student.class, "drafts");
但在提到排序顺序时抛出错误

Sort.by(Sort.Direction.DESC,"lastUpdatedAt").
注意:MongoDB托管在AWS EC2服务上

Sort.by(Sort.Direction.DESC,"lastUpdatedAt").