Today I Learn ✍🏼
- 오늘 하루 가장 인상 깊었던 배움에는 뭐가 있었지?
- 그 배움까지 다가가는데 어떤 어려움이 있었지?
- 그 어려움을 해결하기 위한 나의 시도들은 무엇이 있었지?
- 그 과정에서 나는 무엇을 깨달았고, 어떤 감정/생각이 들었었지?
- 이 상태에서 이후 더 나은 내가 되려면 무엇을 보완하지?
과거에는 됐는데, 지금은 안 되요.
gatewayRouteLocator로 라우팅이 되는데
처음 프로젝트때 했던 application-local.yml로 라우팅이 되지 않는다.
뭐가 문제일까?
게이트 웨이 필터를 열심히 쓰고 게이트웨이에서 유저 서버를 유레카에 등록된 것으로 부르려고 하는데
application.yml 로는 라우팅이 안되고 GatewayConfig로만 가능했다.
작동은 되니까 넘어갈까.. 했지만.. 우선 GatewayConfig를 지우고 application.yml로 라우팅이 왜 안되는지 찾아보려고 한다.
과거 yml, 복사 + 붙여넣기!
혹시? 중간에 띄어쓰기가 잘못된건 아닐까? 하고 처음에 만들었던 프로젝트에서 application.yml을 복사해서 적용해보았다.
application-dev.yml로 라우팅이 된다!
그래서 다시 application-local.yml 로 했더니 안된다.
왼쪽은 되는데 오른쪽은 안된다. 이유가 뭘까?
원인은.. predicates
두개를 비교해서 보니,
predicates에 하나만 있은 경우에는 라우팅이 되고, 2개 이상부터는 작동이 되지 않는 것이었다.
라우팅 못하는 application.yml
더보기
server:
port: 19091
spring:
application:
name: gateway
main:
web-application-type: reactive
cloud:
gateway:
routes:
- id: user
uri: http://192.168.0.10:19092
predicates:
- Path=/users/**
- Path=/auth/**
- id: hub
uri: lb://hub
predicates:
- Path=/hubs/**
- Path=/companies/**
- Path=/shippers/**
- id: product
uri: lb://product
predicates:
- Path=/products/**
- Path=/product-stocks/**
- Path=/product-stock-histories/**
- id: order
uri: lb://order
predicates:
- Path=/orders/**
- Path=/payments/**
- Path=/payment-histories/**
- id: delivery
uri: lb://delivery
predicates:
- Path=/deliveries/**
- Path=/delivery-route-histories/**
- id: ainoti
uri: lb://ainoti
predicates:
- Path=/ai-request-histories/**
- Path=/slack-messages/**
discovery:
locator:
enabled: true
라우팅 할 수 있는 application.yml
더보기
server:
port: 19091
spring:
main:
web-application-type: reactive
application:
name: gateway
cloud:
gateway:
routes:
- id: user
uri: lb://user
predicates:
- Path=/users/**
- id: user2
uri: lb://user
predicates:
- Path=/auth/**
- id: hub
uri: lb://hub
predicates:
- Path=/hubs/**
- id: hub2
uri: lb://hub
predicates:
- Path=/companies/**
- id: hub3
uri: lb://hub
predicates:
- Path=/shippers/**
- id: product
uri: lb://product
predicates:
- Path=/products/**
- id: product2
uri: lb://product
predicates:
- Path=/product-stocks/**
- id: product3
uri: lb://product
predicates:
- Path=/product-stock-histories/**
- id: order
uri: lb://order
predicates:
- Path=/orders/**
- id: order2
uri: lb://order
predicates:
- Path=/payments/**
- id: order3
uri: lb://order
predicates:
- Path=/payment-histories/**
- id: delivery
uri: lb://delivery
predicates:
- Path=/deliveries/**
- id: delivery2
uri: lb://delivery
predicates:
- Path=/delivery-route-histories/**
- id: ainoti
uri: lb://ainoti
predicates:
- Path=/ai-request-histories/**
- id: ainoti2
uri: lb://ainoti
predicates:
- Path=/slack-messages/**
discovery:
locator:
enabled: true
'기술 블로그 (Tech Blog) > Project-coopang' 카테고리의 다른 글
슬랙으로 메세지 보내기 (0) | 2024.10.23 |
---|---|
mapper (0) | 2024.10.23 |
협업 과정에서의 문제 해결과 카프카 메시징 구조 개선 (0) | 2024.10.14 |
@Component, @Configuration + @ConfigurationProperties (0) | 2024.10.02 |
페이징 처리 (0) | 2024.09.23 |