In some applications, I saw people are using @EnableEurekaClient
. And some other example applications are using @EnableDiscoveryClient
.
Is there any difference between these two?
In some applications, I saw people are using @EnableEurekaClient
. And some other example applications are using @EnableDiscoveryClient
.
Is there any difference between these two?
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.
@EnableEurekaCient will initilize the service discovery using eureka server, its like explicitly specifying to use EUREKA
While @EnableDiscovery Client will register dicovery service using the jar available in classpath like consul, Eureka, Kubernetes.
@EnableEurekaClient works only for Eureka if we use @EnableDiscoveryClient we can use any discovery client like Consul other than Eureka
© 2022 - 2024 — McMap. All rights reserved.
@LoadBalanced
was automatically applied, but in current version, it is required explicitly. Thank you. – Lite