Trong Spring Security 6, WebSecurityConfigurerAdapter đã bị loại bỏ; cách cấu hình là khai báo một bean SecurityFilterChain.
Xem đáp án và giải thích
Kiểu cấu hình mới dùng method @Bean SecurityFilterChain filterChain(HttpSecurity http) với lambda DSL, ví dụ http.authorizeHttpRequests(auth -> auth.anyRequest().authenticated()). Khi đọc tutorial cũ trên mạng, cần chú ý chuyển antMatchers thành requestMatchers và authorizeRequests thành authorizeHttpRequests.