[英]Is there any use of registering my config server in Eureka?
I'm specifying the config server URI spring.cloud.config.uri
in the bootstrap.properties
file of all my config server clients.我在所有配置服务器客户端的
bootstrap.properties
文件中指定了配置服务器 URI spring.cloud.config.uri
。
So is there any use of adding an @EnableDiscoveryClient
annotation to it, and registering the configuration service in Eureka?那么给它添加一个
@EnableDiscoveryClient
注解,在Eureka中注册配置服务有什么用呢?
There are various use cases why registering your config server on Eureka could be useful:在 Eureka 上注册您的配置服务器可能会有用的原因有多种:
When using the Spring cloud config service, you have two choices when bootstrapping your application, as mentioned by the documentation :使用 Spring 云配置服务时,在引导应用程序时有两种选择,如文档所述:
When you use a discovery-first setup, all applications can retrieve their configuration by looking up the URL of the configuration service on Eureka:当您使用发现优先设置时,所有应用程序都可以通过在 Eureka 上查找配置服务的 URL 来检索其配置:
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.在这种情况下,应用程序将在 Eureka 上查找名为
config-service
,并将使用给定的主机名和端口进行连接。
Some tools, like Zuul, Spring boot admin, ... will automatically discover all applications and use them, for example:一些工具,如 Zuul、Spring boot admin 等,会自动发现所有应用程序并使用它们,例如:
/{application-name}/**
to the given application. /{application-name}/**
路由转发到给定的应用程序。@EnableDiscoveryClient activates the Netflix Eureka
DiscoveryClient
implementation and tells it to register itself with a service registry. @EnableDiscoveryClient激活
Netflix Eureka
DiscoveryClient
实现并告诉它向服务注册表注册自己。
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 :编辑:将您的应用程序注册到
DiscoveryServer
提供了许多好处,其中一些如下:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.