问题一
使用springboot,权限管理使用spring security,使用内存用户验证,但无响应报错:java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”
这个问题极其坑爹.
究其原因是因为我看的springboot的视频版本太老了导致的:
原先的代码:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("admin").password("123456").roles("USER");
}
如果单纯这样配置,必定报上面的错误。
原因在于Securuty5.0之后,强制性要求提供一个密码编码器才能通过验证,否则必报上面的空值异常
因此,多种解决方案
第一种,使用spring自带的:
此代码摘自官网
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user