一、启动项配置@EnableEurekaServer

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {

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

二、Eureka Server Maven依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

三、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

四、Eureka Client Maven依赖

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

五、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

六、Eureka Client启动 @EnableDiscoveryClient

@SpringBootApplication
@EnableDiscoveryClient
public class ClientApplication {

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

七、Eureka注册中心界面

clipboard.png


阿南
20 声望7 粉丝