未定义类型List

时间:2018-09-04 06:19:45

标签: java spring-security

我想实现Spring Security,但是由于某种原因,当我尝试实现它时出现此错误:

import java.util.List;


@Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return userRepository.findByUsername(username)
                .map(user -> {
                    return new User(
                            user.getLogin(),
                            user.getEncrypted_password(),
                            true,
                            true,
                            true,
                            true,
                            List.of(new SimpleGrantedAuthority(user.getRole()))
                    );
                }).orElseThrow(() -> new UsernameNotFoundException("User with username " + username + " not found"));
    }

此行出现错误:

List.of(new SimpleGrantedAuthority(user.getRole()))
The method of(SimpleGrantedAuthority) is undefined for the type List

您知道如何解决此问题吗?

0 个答案:

没有答案