我是靠谱客的博主 雪白曲奇,这篇文章主要介绍初学spring security,遇到There is no PasswordEncoder mapped for the id "null",现在分享给大家,希望可以做个参考。

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”
初学spring security,使用简单的入门案例遇到这个错,是因为密码加密的原因。
在获取密码是拼接上"{noop}" ,像这个样子"{noop}"+userInfo.getPassword(),可以暂时解决这个问题

@Service(“userService”)
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//数据可以查用户信息
UserInfo userInfo = userDao.findByUsername(username);
//借助getAuthority方法获得用户权限
List<SimpleGrantedAuthority> authority = getAuthority(userInfo.getRoles());
System.out.println(authority);
User user = new User(userInfo.getUsername(),"{noop}"+userInfo.getPassword(),
userInfo.getStatus()==0?false:true,
true,true,true,
getAuthority(userInfo.getRoles()));
return user;
}

最后

以上就是雪白曲奇最近收集整理的关于初学spring security,遇到There is no PasswordEncoder mapped for the id "null"的全部内容,更多相关初学spring内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部