SpringCloud入門01---服務註冊與發現Eureka配置

1.新建一個SpringBoot項目
新建時選中Eureka Server依賴
在這裏插入圖片描述
2.Eureka 配置
2.1在啓動類上添加註解@EnableEurekaServer

@SpringBootApplication
@EnableEurekaServer //註冊中心的服務端
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

2.2配置application.properties文件

#端口號
server.port=8761
#實例地址
eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}
#禁止自己當作服務註冊
eureka.client.register-with-eureka=false
#屏蔽註冊信息
eureka.client.fetch-registry=false
#關閉自我保護(不推薦)
eureka.server.enable-self-preservation=false

#關閉“沒有用於註冊服務器的副本節點”的警告信息
logging.level.com.netflix.eureka=off
logging.level.com.netflix.discovery=off

配置成功訪問頁面如下
在這裏插入圖片描述
此博文僅爲自己學習記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章