개발자 도전기
[Spring] a bean of type 'org.apache.catalina.filters.CorsFilter' that could not be found. 본문
개발공부/Spring
[Spring] a bean of type 'org.apache.catalina.filters.CorsFilter' that could not be found.
jnnjnn 2024. 6. 11. 12:50
문제
cors 설정 중 CorsFilter의 빈을 찾을 수 없다는 오류가 발생했다

원인
SecurityConfiguration에서 CorsFilter 의존성을 주입할 때
import org.apache.catalina.filters.CorsFilter;
를 그대로 import했는데, 나는 CorsConfig 클래스에 @Configuration 어노테이션을 붙여 CorsFilter를 @Bean으로 등록했기 때문이다
해결
private final CorsConfig corsConfig;
CorsConfig를 의존성 주입받고 corsConfig.corsFilter() 형태로 사용했다
.addFilter(corsConfig.corsFilter())
'개발공부 > Spring' 카테고리의 다른 글
[Spring] Lombok @RequiredArgsConstructor로 의존성 주입한 Bean이 null일 때 (0) | 2024.06.19 |
---|---|
[Spring] Negative matches: Did not match: (0) | 2024.06.12 |
[Spring] @Value 어노테이션으로 주입한 값이 null일 때 (0) | 2024.06.07 |
[Spring] 컨트롤러로 요청 시 302 Found 응답 뜰 때 (0) | 2024.06.04 |
[Spring] Encoded password does not look like BCrypt (0) | 2024.05.24 |