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

Let me state this by saying that I am not using Spring Cloud Config directly, it is transitive using the Spring Cloud Hystrix starter.

When only used @EnableHystrix, Spring Cloud also tries to find the configuration server, which is expected to fail, since I am not using it. The application works just fine, as far as I can tell, but the problem is with status checks. Health shows DOWNbecause there is no configuration server.

Looking through the source code of the project, I expect to spring.cloud.config.enabled=falsedisable this functional chain, however this is not what I see.

After upgrading to 1.0.0.RC1(which adds this property) and using @EnableCircuitBreaker:

{
    status: "DOWN",
    discovery: {
        status: "DOWN",
        discoveryClient: {
            status: "DOWN",
            error: "org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.client.discovery.DiscoveryClient] is defined"
        }
    },
    diskSpace: {
        status: "UP",
        free: 358479622144,
        threshold: 10485760
    },
    hystrix: {
        status: "UP"
    },
    configServer: {
        status: "DOWN",
        error: "org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http: //localhost: 8888/bootstrap/default/master":Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect"
    }
}

configprops , . , configClient.

parent: {
    configClientProperties: {
        prefix: "spring.cloud.config",
        properties: {
            password: null,
            discovery: {
                enabled: false,
                serviceId: "CONFIGSERVER"
            },
            name: "bootstrap",
            label: "master",
            env: "default",
            uri: "http://localhost:8888",
            enabled: true,
            failFast: false,
            username: null
        }
    }
},
configClientProperties: {
    prefix: "spring.cloud.config",
    properties: {
        password: null,
        discovery: {
            enabled: false,
            serviceId: "CONFIGSERVER"
        },
        name: "bootstrap",
        label: "master",
        env: "default",
        uri: "http://localhost:8888",
        enabled: false,
        failFast: false,
        username: null
    }
}

, , .

+4
5

, . , , , spring.config.enabled bootstrap.yml( .properties).

+8

, ( ), RC1.

spring.cloud.enabled

:

spring.cloud.config.enabled
+7
  • bootstrap yml direcotry spring.cloud.config.enabled=false.
  • spring , : SPRING_CLOUD_CONFIG_ENABLED=false
  • , , SpringApplication.run:

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

    :

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

+2

, - - .

, pom.xml .

<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>
+1

As for tracking the discovery service (unlike other posts), the installation spring.cloud.config.discovery.enabled: falseworked for me, but only if it was installed in bootstrap (yml / properties), and if I removed the annotation @EnableDiscoveryClientfrom mine Application. I assume this means that you cannot use this annotation for any service where the discovery will not be used from time to time.

0
source

Source: https://habr.com/ru/post/1568346/


All Articles