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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM