1、啓動項配置@EnableEurekaServer
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
2、Eureka Server Maven依賴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
3、Eureka Server配置
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
register-with-eureka: false
server:
enable-self-preservation: false -- 關閉註冊頁面紅色警告
spring:
application:
name: eureka -- 修改應用的名稱
server:
port: 8761
4、Eureka Client Maven依賴
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
5、Eureka Client配置
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/
# instance:
# hostname: clientName -- 自定義跳轉連接
spring:
application:
name: client
6、Eureka Client啓動 @EnableDiscoveryClient
@SpringBootApplication
@EnableDiscoveryClient
public class ClientApplication {
public static void main(String[] args) {
SpringApplication.run(ClientApplication.class, args);
}
}
7、Eureka註冊中心界面