Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 类型列表未定义_Java_Spring Security - Fatal编程技术网

Java 类型列表未定义

Java 类型列表未定义,java,spring-security,Java,Spring Security,我想实现Spring安全性,但由于某些原因,我在尝试实现它时出现了以下错误: import java.util.List; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { return userRepository.findByUsername(username) .map(user -

我想实现Spring安全性,但由于某些原因,我在尝试实现它时出现了以下错误:

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

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

您是使用java 9+构建的吗<代码>列表。在9之前的版本中不可用。我使用java版本“10.0.2”编译错误?检查path变量,如有必要,将jdk升级到jdk 9,然后使用我解决它的方法。事实证明,在Eclipse中,我的项目是针对Java8的。谢谢