在使用Spring-Data-JPA时,创建Sort()对象和PageRequest()
出现如下错误:
‘Sort(org.springframework.data.domain.Sort.Direction, java.util.List<java.lang.String>)’ has private access in ‘org.springframework.data.domain.Sort’
‘PageRequest(int, int, org.springframework.data.domain.Sort)’ has protected access in ‘org.springframework.data.domain.PageRequest’
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 sort= Sort.by(Sort.Direction.DESC,"xxxxxx");
Pageable pageable= PageRequest.of(0, size, sort);
@Override
public List<Type> listTypeTop(Integer size) {
Sort sort= Sort.by(Sort.Direction.DESC,"xxxxxxxxx");
Pageable pageable= PageRequest.of(0, size, sort);
return typeDao.findTop(pageable);
}