我的目标是通过在 application.properties
中设置 spring.applicaton.name
和 server.port
和 eureka.client.serviceUrl.defaultZone
以及 bootstrap.properties
中的 spring.cloud.config.discovery.enabled=true
和 spring.cloud.config.discovery.service-id=cloud-config
来配置spring cloud配置服务器的位置,结果证明是不够的 . 日志中显示以下错误消息:'
com.netflix.discovery.DiscoveryClient : DiscoveryClient_BOOTSTRAP/192.168.1.5:bootstrap - was unable to refresh its cache! status = Cannot execute request on any known server
No instances found of configserver (cloud-config)
根据文档,我将 eureka.client.serviceUrl.defaultZone
移动到了 bootstrap.properties
并成功了 .
我的问题是,如果 spring.application.name
和 server.port
对于eureka客户端在eureka服务器上注册至关重要,那么为什么它们可能在 bootstrap.properties
中为配置客户端而不稳定?
我怀疑配置客户端将首先单独使用 eureka.client.serviceUrl.defaultZone
与eureka服务器连接并获取服务注册信息但不注册自身以便找到配置服务器并拉出一些东西 . 之后,由于配置客户端也是eureka客户端,它使用 application.properties
中的相关参数在eureka服务器上注册 . 作为我怀疑的一些证据,我在应用程序启动期间发现了以下日志:
2017-09-07 06:13:09.651 INFO [bootstrap,,,] 74104 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2017-09-07 06:13:09.817 INFO [bootstrap,,,] 74104 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : The response status is 200
2017-09-07 06:13:09.821 INFO [bootstrap,,,] 74104 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Not registering with Eureka server per configuration
2017-09-07 06:13:37.427 INFO [-,,,] 74104 --- [ restartedMain] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
是吗?