springsecurity

springsecurity旧版本自定义设置用户密码角色

protected void configure(AuthenticationManagerBuilder auth) throws Exception {
 auth.inMemoryAuthentication().withUser("admin").password("123456").roles("ADMIN");
 auth.inMemoryAuthentication().withUser("zhangsan").password("zhangsan").roles("ADMIN");
 auth.inMemoryAuthentication().withUser("demo").password("demo").roles("USER");
}

2.x新版本(进行了加密):

 auth.inMemoryAuthentication() 

.passwordEncoder(new BCryptPasswordEncoder()).withUser("user1") 

.password(new BCryptPasswordEncoder().encode("123456"))  .roles("USER");

原文地址:https://www.cnblogs.com/share-record/p/11735798.html