问题代码:
auth.inMemoryAuthentication().withUser(“user”).password(“password”).roles(“USER”);
报错信息:
There is no PasswordEncoder mapped for the id “null”
报错原因:
密码需要加密
解决问题:
auth .inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser(“user”).password(new BCryptPasswordEncoder().encode(“123456”)).roles(“USER”);
登录成功后显示 <#assign user=Session.SPRING_SECURITY_CONTEXT.authentication.principal/> 用户,${user.username}