Spring Security
一、使用
1.导入Spring Security依赖
org.springframework.boot
spring-boot-starter-security
2.创建一个配置类继承
WebSecurityConfigurerAdapter并且加上==@EnableWebSecurity==,重写==configure(HttpSecurity http)==方法
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
//业务代码
}
}