在这里输入代码
gateway:
discovery:
locator:
enabled: true
routes:
- id: goods
uri: lb://wxzm-goods
predicates:
- After=2010-01-20T17:42:47.789-07:00[America/Denver]
- id: test
uri: lb://wxzm-user
predicates:
- RemoteAddr=192.168.1./255
多个路由 自由第一个路由有用
比如说上面配置
localhost:8888/goods/queryAll 能够访问。(goods 服务 feign user 服务)
localhost:8888/user/querAll 404 (user 服务 feign good服务)
吧id goods test 互换一下。
那么请求的结果就是
localhost:8888/goods/queryAll 404(goods 服务 feign user 服务)
localhost:8888/user/querAll 能够访问。 (user 服务 feign good服务)
请求http://localhost:8888/statistics/feignQueryAll
server:
port: 8888
spring:
application:
name: wxzm-gateway
cloud:
nacos:
discovery:
server-addr: 47.107.232.244:8848
gateway:
discovery:
locator:
enabled: true
routes:
- id: goods
uri: lb://wxzm-goods
predicates:
- After=2010-01-20T17:42:47.789-07:00[America/Denver]
- id: test
uri: lb://wxzm-user
predicates:
- After=2010-01-20T17:42:47.789-07:00[America/Denver]
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
logging:
level:
org.springframework.cloud.gateway: trace
面向未来微服务:熟练掌握Spring Cloud Alibaba
了解课程