springcloud-eureka高可用配置
阿新 • • 發佈:2018-12-13
一、1個eureka-server
注意點:1、新建專案選擇Eureka Server
2、啟動類加註解
3、application.yml配置檔案
eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ #不讓eureka.server自己註冊自己 register-with-eureka: false #將服務端配置成客戶端關閉時展示服務消失:僅僅用於開發環境,生產環境得開啟 server: enable-self-preservation: false spring: application: name: eureka-server #server: # port: 8761
1個Eureka-Client
1、新建專案:
2、啟動類加註解@EnableDiscoveryClient
@SpringBootApplication
@EnableDiscoveryClient
public class LearningApplication {
public static void main(String[] args) {
SpringApplication.run(LearningApplication.class, args);
}
}
3、application.yml檔案
eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ spring: application: name: eureka-client
二、兩或三個Eureka Server ,相互註冊
yml配置檔案
eureka: client: service-url: defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ #不讓eureka.server自己註冊自己 register-with-eureka: false #將服務端配置成客戶端關閉時展示服務消失:僅僅用於開發環境,生產環境得開啟 server: enable-self-preservation: false spring: application: name: eureka-server