我想实现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
您知道如何解决此问题吗?