Spring Cloud의 API Gateway의 의존성을 추가하면 자동으로 Spring Reactive Web이 추가가 되는데 여기서 Spring Web을 추가하면 충돌이 발생
Spring Web은 서블릿 기반의 블로킹 I/O를 사용
Spring Reactive Web(예: spring-cloud-starter-gateway)은 넌블로킹 I/O를 사용
*************************** APPLICATION FAILED TO START ***************************
Description:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
Action:
Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
따라서, Spring Web 의존성이 없으면 HttpServletRequest, HttpServletResponse, Cookie 등을 사용할 수 없게 되는데
HttpServletRequest, HttpServletResponse는 ServerWebExchange으로 대체하고
Cookie는 RequestCookie, ResponseCookie로 대체
public void addJwtToCookie(String token, ServerWebExchange exchange) {
ResponseCookie cookie = ResponseCookie.from(AUTHORIZATION_HEADER, token)
.path("/")
.httpOnly(true)
.build();
exchange.getResponse().addCookie(cookie);
}
'Various Error' 카테고리의 다른 글
[Redis] java.net.UnknownHostException (0) | 2024.08.28 |
---|---|
[HMAC-SHA] WeakKeyException (0) | 2024.08.27 |
[IntelliJ / FeignClient] 의존성 추가 후 어노테이션 인식 불가 (0) | 2024.08.22 |
[Eureka] Eureka Client의 UnsatisfiedDependencyException 에러 (0) | 2024.08.20 |
[JSON] HttpMediaTypeNotAcceptableException (0) | 2024.08.19 |