Cannot disable Spring Cloud Config via spring.cloud.config.enabled:false

后端 未结 5 1518
无人及你
无人及你 2021-01-04 03:51

Let me preface this by saying that I\'m not using Spring Cloud Config directly, it is transitive via Spring Cloud Hystrix starter.

When only using @EnableHystr

相关标签:
5条回答
  • 2021-01-04 04:25

    I had the same problem, I wanted to have the config server disabled (as we do not need it so far) but the property mentioned above is not correct for RC1 at least.

    spring.cloud.enabled
    

    Should be:

    spring.cloud.config.enabled
    
    0 讨论(0)
  • 2021-01-04 04:38

    The config server is needed during bootstrap, and that's where the parent property sources come from. It looks like all you need to do is move your spring.cloud.config.enabled property to bootstrap.yml (or .properties).

    0 讨论(0)
  • 2021-01-04 04:42

    Regarding the discovery service followup (looks like no other posts on that), setting spring.cloud.config.discovery.enabled: false worked for me, but only if it was set in bootstrap(yml/properties) and if I removed the @EnableDiscoveryClient annotation from my Application class. I guess this means one cannot use that annotation for any service where discovery will not be used at times.

    0 讨论(0)
  • 2021-01-04 04:43
    • You can put a bootstrap properties or yml to your resource direcotry or your applications directory and add spring.cloud.config.enabled=false. OR
    • You can disable spring cloud config server client by adding an environment variable: SPRING_CLOUD_CONFIG_ENABLED=false OR
    • Config server client can be disabled by adding a parameter to your app, if you pass the args to parameters to SpringApplication.run:

      public static void main(String[] args) throws Exception { SpringApplication.run(YourApplication.class, args); }

      and start the app by:

      java -jar yourapplication.jar --spring.cloud.config.enabled=false

    0 讨论(0)
  • 2021-01-04 04:49

    I tried all of the above changes and still config client never stopped somehow.

    The only way I was able to disable it by using following exclusion in my project's pom.xml file.

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-config-client</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题