背景
MongoDB分页工具,代码报错:
提示错误1
'Sort(java.util.List<org.springframework.data.domain.Sort.Order>)' has protected access in 'org.springframework.data.domain.Sort'
提示错误2
'Sort(org.springframework.data.domain.Sort.Direction, java.util.List<java.lang.String>)'
has private access in 'org.springframework.data.domain.Sort'
原因
springboot2.2.1(含)以上的版本Sort已经不能再实例化了,构造方法已经是私有或者是protected的了!
解决方法
我们可以改用Sort.by获得Sort对象,Sort.by()可以一个或多个字段排序。
相关文章
Spring-Data-Jpa的Sort排序时遇到的问题 has private access in ‘org.springframework.data.domain.Sort’
https://blog.csdn.net/qq_35953966/article/details/104061854