【问题标题】:How to override specific routes in spring cloud gateway in properties based configuration?如何在基于属性的配置中覆盖 Spring Cloud Gateway 中的特定路由?
【发布时间】:2022-11-03 22:31:54
【问题描述】:

我有 2 个配置文件 test 和 myteam,因此有 2 个配置文件 application-test.yml 和 application-myteam.yml

application-test.yml 包含来自所有应用程序的路由(基于主分支主机) 例如:

spring:
  cloud:
    gateway:
      routes:
        - id: app1
          uri: https://app1.company.com
          predicates:
            - Path = /api/msp/app1/someOperation/{id}
          filters:
            - StripPrefix=2
          

以及其他应用程序的其他几条路线。

我想要实现的是仅覆盖路由的子集并保持其他路由相同(最好不复制测试中的所有内容)到 myteam。在上面的示例中,我只想覆盖 id 为 app1 的路由,同时保持所有其他路由与 myteam 配置文件中的测试相同。

【问题讨论】:

    标签: spring-boot spring-cloud spring-cloud-gateway


    【解决方案1】:

    你可以在 application.properties 中尝试这样的事情:

    spring.cloud.gateway.routes[0].uri=http://service1:8081

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2023-03-09
      • 2020-02-29
      • 2021-06-12
      • 2021-01-04
      • 2019-12-11
      • 1970-01-01
      • 2019-09-23
      • 1970-01-01
      相关资源
      最近更新 更多