"spring-cloud-starter-gateway " is deprecated and "spring-cloud-starter-gateway-server-webflux " is preferred to use.
When you migrate remember to migrate the route path configured in the property or yml file also.
eg: let's take a simple scenario where you have service running on "http://localhost:8001/greet" and gateway is configured with port '9191'
your old properties will looks like beow.
----------------------------------------------------------------------
## As per Old configuration with spring.cloud.gateway.routes
server:
port: 9191
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: greet-service
uri: http://localhost:8001
predicates:
- Path=/greet/**
----------------------------------------------------------------------------
There won't any issue, but when you run the api-gateway it will give a warning message with sample content like below. api-gateway automatically recognized the usage of newer server-webflux and map old properties with new server-webflux properties
----------------------------------------------------------------------------
The use of configuration keys that have been renamed was found in the environment:
Property source 'Config resource 'class path resource [application.yml]' via location 'optional:classpath:/'':
Key: spring.cloud.gateway.routes[0].id
Line: 10
Replacement: spring.cloud.gateway.server.webflux.routes[0].id
Key: spring.cloud.gateway.routes[0].uri
Line: 11
Replacement: spring.cloud.gateway.server.webflux.routes[0].uri
Key: spring.cloud.gateway.routes[0].predicates[0]
Line: 13
Replacement: spring.cloud.gateway.server.webflux.routes[0].predicates[0]
Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.
--------------------------------------------------------------------------------------
Solution
Simply add 'server-webflux' just between gateway and routes
-------------------------------------------------------------------------------------------
## new configuration with spring.cloud.gateway.server.webflux.routes
## Note : server.webflux comes just after 'gateway'
server:
port: 9191
spring:
application:
name: api-gateway
cloud:
gateway:
server:
webflux:
routes:
- id: greet-service
uri: http://localhost:8001
predicates:
- Path=/greet/**
# filters:
No comments:
Post a Comment