1,797
社区成员
发帖
与我相关
我的任务
分享

我之前是1.10.7换成1.10.11之后完美解决,参考下面的博文
https://blog.csdn.net/qq_36324685/article/details/80767928 public List<CountIdDTO> listGroupCount(String groupField, String collectionName) {
Aggregation agg = Aggregation.newAggregation(Aggregation.group(groupField).count().as("count"),
Aggregation.project("count").and(groupField).as("objectId"));
AggregationResults<CountIdDTO> results = mongoTemplate.aggregate(agg, collectionName, CountIdDTO.class);
List<CountIdDTO> countIdDTO = results.getMappedResults();
return countIdDTO;
}
我写的代码是这样,测试错误
