level 1
little光1
楼主
Service包中的UserServiceImpl类中的Sort sort=new Sort(Sort.Direction.ASC,"id");报错了 不知道该怎么解决 望解答 谢谢
出现错误:The constructor Sort(Sort.Direction, String) is undefined
代码:
package service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import dao.UserDao;
import entity.User;
@Service
public class UserServiceImpl implements UserService{
@Autowired
UserDao userDao;
@Override
public Page<User> list(int start,int size) {
start=start<0?0:start;
Sort sort=new Sort(Sort.Direction.ASC,"id");//该句出现错误
Pageable pageable=PageRequest.of(start, size,sort);
return userDao.findAll(pageable);
}
2020年03月11日 02点03分
1
出现错误:The constructor Sort(Sort.Direction, String) is undefined
代码:
package service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import dao.UserDao;
import entity.User;
@Service
public class UserServiceImpl implements UserService{
@Autowired
UserDao userDao;
@Override
public Page<User> list(int start,int size) {
start=start<0?0:start;
Sort sort=new Sort(Sort.Direction.ASC,"id");//该句出现错误
Pageable pageable=PageRequest.of(start, size,sort);
return userDao.findAll(pageable);
}