Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between EnableEurekaClient and EnableDiscoveryClient?

People also ask

What is EnableEurekaClient?

The @EnableEurekaClient annotation makes your Spring Boot application act as a Eureka client. The main Spring Boot application is as given below − package com.

What is difference between Eureka server and Eureka client?

A Eureka client registers to a Eureka Server. Because a Eureka Instance registers to Eureka Server, so it is a client. Because a Eureka Service offers api to others, so it can be discovered by others, so it is a Instance.

What is Eureka client serviceUrl defaultZone?

eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ In the preceding example, "defaultZone" is a magic string fallback value that provides the service URL for any client that does not express a preference (in other words, it is a useful default).

Which is the annotation used for denoting Eureka client?

Add @EnableEurekaClient annotation to declare this service as Eureka Client.


There are multiple implementations of "Discovery Service" (eureka, consul, zookeeper). @EnableDiscoveryClient lives in spring-cloud-commons and picks the implementation on the classpath. @EnableEurekaClient lives in spring-cloud-netflix and only works for eureka. If eureka is on your classpath, they are effectively the same.


Discovery service concept in spring cloud is implemented in different ways like Eureka, consul, zookeeper etc. If you are using Eureka by Netflix then @EnableEurekaClient is specifically for that. But if you are using any other service discovery including Eureka you can use @EnableDiscoveryClient.


In terms of its practicality and simplicity, if the registered center is eureka, then @EnableEurekaClient is recommended. If it is another registration center, @EnableDiscoveryClient is recommended.