gpt4 book ai didi

java - 如果在其他配置文件中添加路由,为什么主配置中的路由未加载?

转载 作者:行者123 更新时间:2023-12-02 09:42:25 25 4
gpt4 key购买 nike

我正在设置一个具有 3 个环境(DEV、QA、PROD)的 Spring Cloud Gateway 应用程序。所有主要路由都放在主配置文件中,但我还有其他路由需要在环境配置文件中声明。请检查下面的示例配置文件:

test.yaml(主)

 spring:
cloud:
gateway:
routes:
- id: test-routes-1
uri: http://testing1.com/
- id: test-routes
uri: http://testing.com/

测试-dev.yaml

 spring:
cloud:
gateway:
routes:
- id: test-routes
uri: http://testing-dev.com/

当我使用此配置文件部署应用程序时,只有开发路由可用,而主配置中的其他路由不可用。我该如何解决这个问题?

最佳答案

这是默认行为。据我所知,没有办法解决这个问题。

Profile-specific properties are loaded from the same locations as standard application.properties, with profile-specific files always overriding the non-specific ones, whether or not the profile-specific files are inside or outside your packaged jar.

参见https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-profile-specific-properties

关于java - 如果在其他配置文件中添加路由,为什么主配置中的路由未加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56968994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com