springsecurity舊版本自定義設置用戶密碼角色spring
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");
}ui
2.x新版本(進行了加密):加密
auth.inMemoryAuthentication() code
.passwordEncoder(new BCryptPasswordEncoder()).withUser("user1") it
.password(new BCryptPasswordEncoder().encode("123456")) .roles("USER");io