首页 > 解决方案 > 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-netflixspring-cloud-config

解决方案


您需要在 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 文档中查看更多信息。


推荐阅读