springboot2.2.1(含)以上的版本Sort已经不能再实例化了,构造方法已经是私有的了!
'Sort(org.springframework.data.domain.Sort.Direction, java.util.List<java.lang.String>)'
has private access in 'org.springframework.data.domain.Sort'
我们可以改用Sort.by获得Sort对象
public static PageRequest pageRequest(Integer pageSizeDef, String orderByColumnDef, Sort.Direction sortDirection){
Integer pageIndex = HttpServletUtil.getParameterInt("page", 1);
Integer pageSize = HttpServletUtil.getParameterInt("size", pageSizeDef);
String orderByColumn = HttpServletUtil.getParameter("orderByColumn", orderByColumnDef);
String direction = HttpServletUtil.getParameter("isAsc", sortDirection.toString());
// Sort sort = new Sort(Sort.Direction.fromString(direction), orderByColumn);
// return PageRequest.of(pageIndex-1, pageSize, sort);
return PageRequest.of(pageIndex-1, pageSize, Sort.by(Sort.Direction.fromString(direction), orderByColumn));
}