Spring Boot 集成 Apollo 報 [Cause: [status code: 404] Could not find config for namespace

Spring Boot 集成 Apollo 報以下異常:java

10:11:21.891 [main] WARN  c.c.f.a.i.RemoteConfigRepository - Load config failed, will retry in 1 SECONDS. appId: 201909261015778899, cluster: platform-tw, namespaces: application

10:11:35.087 [main] WARN  c.c.f.apollo.internals.DefaultConfig - Could not load config for namespace application from Apollo, please check whether the configs are released in Apollo! Return default value now!

10:12:28.291 [Apollo-RemoteConfigRepository-1] WARN  c.c.f.a.i.AbstractConfigRepository - Sync config failed, will retry. Repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository, reason: Load Apollo Config failed - appId: 201909261015778899, cluster: platform-tw, namespace: application, url: http://127.0.0.1:8001/configs/pf-core/platform-tw/application?ip=127.0.0.1&messages=%7B%22details%22%3A%7B%22pf-core%2Bplatform-tw%2Bapplication%22%3A5%2C%22pf-core%2Bdefault%2Bapplication%22%3A3%7D%7D [Cause: [status code: 404] Could not find config for namespace - appId: 201909261015778899, cluster: platform-tw, namespace: application, please check whether the configs are released in Apollo!]

開始有點奇怪,我在項目中並未使用application命名空間,application.properties配置以下:redis

# 應用全局惟一的身份標識
app.id = 20190926778899
# Apollo Meta Server 地址
apollo.meta = http://127.0.0.1:8011
# 自定義本地配置文件緩存路徑
# apollo.cacheDir = ./config
apollo.cluster = platform-tw
# 設置在應用啓動階段就加載 Apollo 配置
apollo.bootstrap.enabled = true
# 注入 application namespace
apollo.bootstrap.namespaces = redis

經查看源碼,開啓阿波羅配置註解@EnableApolloConfig(),默認命名空間爲application,此處需注入命名空間爲redis屬性配置,天然會出現不能加載異常,正常作法爲把註解修改成:@EnableApolloConfig(value = {"redis"})bootstrap

相關文章
相關標籤/搜索