apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
29.13k stars 10.2k forks source link

项目配置了apollo不起作用 #2215

Closed zhaoyunxing92 closed 4 years ago

zhaoyunxing92 commented 5 years ago

我用1.4.0的版本,但是yml文件不起用,文件已经拉倒本地了

yml配置

app:
  id: spring-boot-apollo
apollo:
  meta: http://127.0.0.1:8080
  cacheDir: ./apolloconfig 
  bootstrap:
    enabled: true
    namespaces: application.yml
    eagerLoad:
      enabled: true

拉取的配置信息 cache

nobodyiam commented 5 years ago

需要确保本地没有填写server.port属性

zhaoyunxing92 commented 5 years ago

我本地只设置了apollo的配置,其他都在apollo上配置的

nobodyiam commented 5 years ago

可以参考一下spring-cloud-zuul

zhaoyunxing92 commented 5 years ago

现在问题是application.yml不行,只能用application.properties

nobodyiam commented 5 years ago

我使用spring-cloud-zuul测试了是没问题的

  1. 在apollo创建application.yml 如http://106.12.25.204:8070/config.html?#/appid=spring-cloud-zuul
server:
  port: 9090
zuul:
  routes:
    test:
      path: /**
      url: https://github.com
  1. 修改Application.java,注入application.yml配置
@EnableApolloConfig("application.yml")
  1. 修改ZuulPropertiesRefresher.java监听application.yml的变化

这步非必须,只是为了能监听配置变化,重新刷新zuul的路由

  @ApolloConfigChangeListener(interestedKeyPrefixes = "zuul.", value = "application.yml")
  public void onChange(ConfigChangeEvent changeEvent) {
    refreshZuulProperties(changeEvent);
  }
  1. 配置application.properties中的apollo.meta地址

  2. 启动程序

程序会以前面配置的端口启动

zhaoyunxing92 commented 5 years ago

好的,十分感谢,我等下再试试看

couples commented 4 years ago

客户端1.5.1,在配置文件中配置apollo.bootstrap.namespaces: application,application.yml 读取不到application.yml namespace中的配置 用@EnableApolloConfig("application.yml")这个是可以的;不知道是什么原因!

nobodyiam commented 4 years ago

@couples 打开debug日志看看

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in 14 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has not had activity in the last 14 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.