Spring Cloud Gateway配置文件配置讲解

spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      routes:
        - id: data-service1  #请求 http://localhost:8100/data-service1/test会转发到data-producer服务
          uri: lb://data-producer  #在服务注册中心找服务名为 data-producer的服务
          predicates:
            - Path=/data-service1/*  #设置路由断言,代理servicerId为data-service1的/ data-service1 /路径
          filters:
            - StripPrefix=1
        - id: data-service2  # 请求 http://localhost:8100/data-service2/test转发到 http://localhost:8080/test
          uri: http://localhost:8080
          predicates:
            - Path=/data-service2/*
          filters:
            - StripPrefix=1  #前缀, 在当前路径匹配中表示去掉第一个前缀 /data-service2

  

 

posted @ 2020-03-20 15:09  kitterKing  阅读(10846)  评论(0编辑  收藏  举报