Sort报错信息’Sort(org.springframework.data.domain.Sort.Direction, java.util.List<java.lang.String>)’ has private access in ‘org.springframework.data.domain.Sort’
PageRequest报错信息’PageRequest(int, int, org.springframework.data.domain.Sort)’ has protected access in ‘org.springframework.data.domain.PageRequest’
因为SpringBoot2.2.1(含)以上的版本Sort已经不能再实例化了,构造方法已经是私有的了!可以改用Sort.by获得Sort对象和PageRequest.of
Sort sort = Sort.by(Sort.Direction.DESC,"updateTime");
Pageable pageable = PageRequest.of(0, size, sort);
转载请注明:路飞博客 » Sort和PageRequest方法过时问题的解决办法
热门推荐
- Java随机生成姓名、手机号、邮箱、住址代码
- vivo-2021Java笔试-智能手机产能问题
- vivo-2021Java笔试-愚人节拆礼品盒问题
- com.mysql.jdbc.Driver和com.mysql.cj.jdbc.Driver的区别 serverTimezone设定
- Cannot resolve method findOne(java.lang.Long)
- NotBlank过时处理和@NotEmpty、@NotNull、@NotBlank 的区别
- Server Tomcat v8.5 Server at localhost was unable to start within 45
- request和response的setCharacterEncoding()方法