I am new to spring security. I was trying to creating my first project using spring boot and spring security with the help of this tutorial
In UserServiceImpl file there is a function mapRolesToAuthorities, it takes Collection < Role > roles as a parameter.
Now the problem is, when I try to stream and map the roles like this
private Collection < ? extends GrantedAuthority >
mapRolesToAuthorities(Collection < Role > roles)
{
return roles.stream().map(role - > new
SimpleGrantedAuthority(role.getRolename()))
.collect(Collectors.toList());
}
It shows error that
role cannot be resolved to a variable
.
How can I resolve this issue?
There is a typo with extra space in lambda operator:
role - >
should be
role ->