본문 바로가기
Error

Spring Cloud Gateway Config Error

by YoonJong 2024. 3. 24.
728x90

 

아래와 같은 에러 발생

org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar$RouterFunctionHolder

 

 

pom.xml 설정파일

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway-mvc</artifactId>
</dependency>

 

application.yml 파일 

server:
  port: 8000

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://localhost:8761/eureka

spring:
  application:
    name: apigateway-service
  cloud:
    gateway:
      routes:
        - id: first-service
          uri: http://localhost:8081/
          predicates:
            - Path=/first-service/**
        - id: second-service
          uri: http://localhost:8082/
          predicates:
            - Path=/second-service/**

 

spring.cloud.gateway.routes 부분과 pom.xml 에서 artifactId 차이로 인해 발생.

처음 프로젝트 생성 시, Gateway 의존성을 추가하면 자동으로 gateway-mvc 로 등록된다.

mvc 를 제거하고 다시 빌드 하면 정상적으로 진행가능

 

pom.xml 수정

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
728x90

댓글