重写WebSecurityConfigurerAdapter不生效

1.简单写了个springboot security

继承WebSecurityConfigurerAdapter后重写了configure(HttpSecurity http)发现一直没生效

@Component
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //表单登录 方式
        http.formLogin()
                .loginPage("/authentication/require")
                //登录需要经过的url请求
                .loginProcessingUrl("/authentication/form")
                .and()
                //请求授权
                .authorizeRequests()
                //任何请求
                .anyRequest()
                //需要身份认证
                .authenticated()
                .and()
                //关闭跨站请求防护
                .csrf().disable();

    }
}

图片说明图片说明

请求被拦截也是用的security默认的地址

https://www.cnblogs.com/hyl8218/p/6212603.html

少了一个注解
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled=true)

https://www.oschina.net/question/863648_2289045