我正在研究Spring Security配置,发现配置内存身份验证的最常见方法是使用configureGlobal()method:
@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
auth
.inMemoryAuthentication()
.withUser("user").password("userPwd").roles("USER");
}
}
Run Code Online (Sandbox Code Playgroud)
但还有另一种方式,这是不太广泛使用,覆盖configure()从方法WebSecurityConfigurerAdapter:
@Configuration
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication(
.withUser("user").password("userPwd").roles("USER");
}
}
Run Code Online (Sandbox Code Playgroud)
我只是想知道,它们之间有什么区别,使用configureGlobal()方法的重点是configure()什么?