1. 문제 발견
WebSecurityConfigurerAdapter를 사용할 수 없음
2. 문제 이유
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
Spring Security without the WebSecurityConfigurerAdapter
<p>In Spring Security 5.7.0-M2 we <a href="https://github.com/spring-projects/spring-security/issues/10822">deprecated</a> the <code>WebSecurityConfigurerAdapter</code>, as we encourage users to move towards a component-based security configuration.</p> <p
spring.io
스프링 공식 사이트에서 WebSecurityConfigurerAdapter는 더이상 사용하지 않고
Spring Security 5.4에서는 SecurityFilterChain Bean을 생성하여 HttpSecurity를 구성하는 기능을 도입했다는 내용
3. 문제 해결
WebSecurityConfigurerAdapter 대신 SecurityFilterChain Bean을 생성
@Bean
protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/api/hello").permitAll()
.anyRequest().authenticated();
return http.build();
}
끝!
'JAVA > SpringBoot' 카테고리의 다른 글
[SpringBoot] module java.base does not open java.lang 에러 (0) | 2023.03.20 |
---|---|
[SpringBoot] Execution failed for task ':test'. 에러 (0) | 2022.10.20 |
[스프링부트] 롬복 Lombok 라이브러리 추가(Gradle Project) (0) | 2022.10.19 |
[자바] 처음 설치하고 자바 버전 1.8로 변경하기 (0) | 2022.05.30 |
[자바] 환경변수 설정 (0) | 2022.05.30 |