spring security 5.0 密码未加密报错

使用spring security5.0后,配置文件中直接写普通的密码如:123456,会报错:

java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"

这是因为spring security5.0以后默认需要选择密码加密方式,如果还像之前版本直接配置未加密密码,就会报上面这个错误当然啦,如果还想用简单密码的话,spring security还是给了两个方案,一种是在配置文件中配置:

<bean id="passwordEncoder" class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/>

l另一种就是在你配置密码那里加上{noop}如:{noop}123456

<security:user name="zhangsan" password="zhangsan" authorities="ROLE_ADMIN"/>

猜你喜欢

转载自www.cnblogs.com/lly001/p/9474844.html
今日推荐