Spring Boot 集成 Apollo 报如下异常:

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配置如下:

# 应用全局唯一的身份标识
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"})

09-26 16:17