這篇文章將為大家詳細講解有關使用SpringBoot如何實現(xiàn)注冊與發(fā)現(xiàn)服務,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
微服務
實踐“微服務”自然要學習如何做服務注冊與發(fā)現(xiàn)
基于SpringBoot來進行微服務的學習,自然選擇了與之息息相關的SpringCloud;當然可以選擇其他的技術進行,比如dubbo
也可以用zookeeper來實現(xiàn)服務注冊與發(fā)現(xiàn),至于zookeeper來實現(xiàn)此功能好還是不好,各家之言都有
SpringCloud
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems .SpringCloud
SpringCloud 包含了 Distributed/versioned configuration、Distributed/versioned configuration等很多子項目。
服務注冊與發(fā)現(xiàn)
SpringCloud模塊
spring-cloud-starter-eureka-server
工程module
服務注冊中心
創(chuàng)建discovery module,并在 build.gradle中引入 spring-cloud-starter-eureka-server依賴
apply plugin: 'org.springframework.boot' dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:"+ springCloudVersion } } repositories { mavenCentral() } dependencies { compile ('org.springframework.cloud:spring-cloud-starter-eureka-server') } jar { baseName = 'discovery-bootcwenao' }