使用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"/>