Spring Cloud Eureka 2 (Eureka Server搭建服務註冊中心)
阿新 • • 發佈:2018-01-20
class XML bsp gist client intellij 嘗試 ati register
工具:IntelliJ IDEA 2017.1.2 x64、maven3.3.9
打開IDE file===>new===>project
next
next
選擇相應的依賴
next
finish
查看下上述我們選的兩個依賴在pom.xml中
通過@EnableEurekaServer註解啟動一個服務註冊中心
在默認情況下該服務註冊中心會將自己作為客戶端來嘗試註冊它自己,所以我們需要禁用它的客戶端行為,只需在application.properties中做如下配置:
# 指定服務的端口號
server.port=1111
# 註冊中心實例名稱
eureka.instance.hostname=localhost
# 表示不向註冊中心註冊自己
eureka.client.register-with-eureka=false
# 由於註冊中心的職責就是維護服務實例並不需要去檢索實例所以設置為false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
啟動項目
通過http://localhost:1111訪問服務註冊中心頁面
基於eureka server的服務註冊中心搭建完成。
Spring Cloud Eureka 2 (Eureka Server搭建服務註冊中心)