spring-cloud-netflix - How to use Service Discovery with Spring-Cloud-Config
问题描述
Reading this documentation: https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html
I can see how to configure Spring-Cloud-Config server to register with Eureka. What I don't see is how to configure the Spring-Cloud-Config client application to discover the Spring-Cloud-Config server via Eureka.
Is it safe to assume if I have a Spring-Boot app that needs to contact Spring-Cloud-Config server to retrieve properties, that just annotating the app with @DiscoveryClient will be enough to automatically locate the Eureka server, discover the location of Spring-Cloud-Config and retrieve properties? It seems like I would at least need to configure the client with the Spring-Cloud-Config server's service ID. But I don't see anywhere how to do that.
解决方案
您需要在 Spring Cloud Config Client 中提供 serviceId 并启用配置服务发现bootstrap.properties
。
# Flag to indicate that config server discovery is enabled (config server URL will be looked up via discovery).
spring.cloud.config.discovery.enabled=true
# Service id to locate config server.
spring.cloud.config.discovery.serviceId=yourConfigServiceId
在Discovery First Bootstrap 文档中查看更多信息。
推荐阅读
- python - 如果数组列表的长度非常大,如何以更快的方法检查输入数组是否与数组列表最相似?
- javascript - 发送电子邮件和调用模式后,提交按钮需要永久禁用
- regex - 如何检查字符串是否包含在 RegExp 中传递的字符?
- event-sourcing - EventStore - 使用什么版本?
- python-3.x - 停止程序后是否有保留字/关键字继续?
- html - 即使正确的网格系统,Bootstrap4 列也会堆叠而不是并排放置
- javascript - javascript to typescript:混合基于原型的对象和基于类的对象
- apache-kafka - 在 Kafka 生产者上启用幂等性是否会降低吞吐量
- python - on_message 等待用户对消息做出反应或超时,然后机器人再次发送另一条带有反应的消息
- javascript - 在 JS 控制台中运行代码时收到错误消息