spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

bootstrap.yml consul Config is unavailable #720

Closed iqolome closed 3 years ago

iqolome commented 3 years ago

Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies -->
        <spring-boot-dependencies.version>2.4.5</spring-boot-dependencies.version>

        <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies -->
        <spring-cloud-dependencies.version>2020.0.2</spring-cloud-dependencies.version>

Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.

application.yml is available

spring: 
  config:
    import: optional:consul:qolome-server:8500
  application:
    name: cloud-collector
  cloud:
    consul:
      discovery:
      config: # 配置中心设置   
        enabled: true # 启用配置中心
        prefixes:
        - configuration
        format: yaml # YML格式文件
        data-key: data # 为应用配置的key名字,值为整个应用配置的字符串。
        profile-separator: ':' # 环境分隔符,默认值 ","
        default-context: cloud-common-config # 默认加载配置
        watch:
          enabled: true # 启用配置自动刷新
          wait-time: 1 # 请求 consul api 的延迟,单位:秒
          delay: 10000 # 刷新频率,单位:毫秒

bootstrap.yml is unavailable


spring: 
  config:
    import: optional:consul:qolome-server:8500
  application:
    name: cloud-collector
  cloud:
    consul:
      discovery:
      config: # 配置中心设置   
        enabled: true # 启用配置中心
        prefixes:
        - configuration
        format: yaml # YML格式文件
        data-key: data # 为应用配置的key名字,值为整个应用配置的字符串。
        profile-separator: ':' # 环境分隔符,默认值 ","
        default-context: cloud-common-config # 默认加载配置
        watch:
          enabled: true # 启用配置自动刷新
          wait-time: 1 # 请求 consul api 的延迟,单位:秒
          delay: 10000 # 刷新频率,单位:毫秒
spencergibb commented 3 years ago

using the new spring.config.import does not use bootstrap. It is a feature. If you need bootstrap and don't want to use spring.config.import, add spring-cloud-starter-bootstrap.