I'm specifying the config server URI spring.cloud.config.uri
in the bootstrap.properties
file of all my config server clients.
So is there any use of adding an @EnableDiscoveryClient
annotation to it, and registering the configuration service in Eureka?
There are various use cases why registering your config server on Eureka could be useful:
When using the Spring cloud config service, you have two choices when bootstrapping your application, as mentioned by the documentation :
When you use a discovery-first setup, all applications can retrieve their configuration by looking up the URL of the configuration service on Eureka:
spring.cloud.config.discovery.enabled=true
spring.cloud.config.uri=http://config-service
In this case, the application will look for a service named config-service
on Eureka, and will use the given hostname and port to connect.
Some tools, like Zuul, Spring boot admin, ... will automatically discover all applications and use them, for example:
/{application-name}/**
to the given application. @EnableDiscoveryClient activates the Netflix Eureka
DiscoveryClient
implementation and tells it to register itself with a service registry.
So, without this annotation, your application will not able to register itself to any Registry. And hence will not be discovered from any service as well.
Edit : Registering your application to DiscoveryServer
provides many benefits, some of them are below :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.