The method map(Function<? super Role,? extends R>) in the type Stream<Role> is not applicable for the arguments ((<no type> r) -> {})

二次信任 提交于 2020-02-29 09:16:26

问题


Why i am getting this error while using GrantedAuthority .

1 CustomUserDetails class.

public class CustomUserDetails extends User implements UserDetails {

    public CustomUserDetails(final User user) {
        super(user);
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return getRoles().stream().map( r -> {

            new SimpleGrantedAuthority(r.getRole().name());

        }  ).collect(Collectors.toList());
    }
  1. Role class.

    @Entity(name = "ROLE") public class Role { @Id @Column(name = "ROLE_ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;

    @Column(name = "ROLE_NAME")
    @Enumerated(EnumType.STRING)
    @NaturalId
    private RoleName role;
    
    @ManyToMany(mappedBy = "roles", fetch = FetchType.LAZY)
    @JsonIgnore
    private Set<User> userList = new HashSet<>();
    

来源:https://stackoverflow.com/questions/60118056/the-method-mapfunction-super-role-extends-r-in-the-type-streamrole-is-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!