@Configuration
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
/**
* authenticated 英 [ɔːˈθentɪkeɪtɪd] v 认证,证明…是真实的;证实
* authorize 英 [ˈɔːθəraɪz] vt 批准;授权
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin() //表单认证方式
.and()
// 授权请求,授权任何请求,都需要认证
.authorizeRequests().anyRequest().authenticated(); // 所有进入应用的HTTP请求都要进行认证
}
}
默认就是表单认证方式,访问:http://localhost:8080/hello