@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
String myPassword = this.password().encode("123456");
auth.inMemoryAuthentication().withUser("tom").password(myPassword).roles("admin");
}
@Bean
PasswordEncoder password()
{
return new BCryptPasswordEncoder();
}
}
Spring security用配置类配置登录账号密码
最新推荐文章于 2024-07-02 09:43:40 发布