SpringCloud @EnableDiscoveryClient

2023-06-07 15:39 更新

Spring Cloud Commons提供了@EnableDiscoveryClient批注。這將尋找META-INF/spring.factories與DiscoveryClient接口的實現(xiàn)。Discovery Client的實現(xiàn)在org.springframework.cloud.client.discovery.EnableDiscoveryClient鍵下將配置類添加到spring.factories。DiscoveryClient實現(xiàn)的示例包括Spring Cloud Netflix Eureka,Spring Cloud Consul發(fā)現(xiàn)Spring Cloud Zookeeper發(fā)現(xiàn)。

默認情況下,DiscoveryClient的實現(xiàn)會自動將本地Spring Boot服務(wù)器注冊到遠程發(fā)現(xiàn)服務(wù)器??梢酝ㄟ^在@EnableDiscoveryClient中設(shè)置autoRegister=false來禁用此行為。

 不再需要?@EnableDiscoveryClient?。您可以在類路徑上放置?DiscoveryClient?實現(xiàn),以使Spring Boot應(yīng)用程序向服務(wù)發(fā)現(xiàn)服務(wù)器注冊。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號