How to selectively disable Eureka discovery client with Spring?

With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:

spring.cloud.service-registry.auto-registration.enabled=false
eureka.client.enabled=false
eureka.client.serviceUrl.registerWithEureka=false

You can disable eureka client in application.yml using this:

eureka:
  client:
    enabled: false

It's also for one profile


Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:

@Profile("!development")
@Configuration
@EnableDiscoveryClient
public class EurekaClientConfiguration {
}

It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".

Hope that helps,


Same issue here. You can simply put in your application property file the following configuration:

  spring:
    profiles: development

  eureka:
    instance:
      hostname: localhost
    client:
      registerWithEureka: false
      fetchRegistry: false