eureka client, server, fast build, and high availability

1. Build a project with idea:
use spring initializr:
and then create a server or client as shown in the figure. One thing to note : Eureka Server integrates web dependencies, but the client does not, so if you create a client, you must add web dependencies, otherwise it will not start!
Insert picture description here

Server:

1. After the construction project is completed: In the startup class, add a comment: @EnableEurekaServer to
Insert picture description here
write the configuration file:

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
    register-with-eureka: false #不要把自己也注册进来
  server:
    enable-self-preservation: false #这里不要自我保护,client下线就直接反映出来。
spring:
  application:
    name: eureka
server:
  port: 8761

Client:

Startup class with annotation: @EnableDiscoveryClient
Insert picture description here
configuration file plus:

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
#  instance:
#    hostname: client #这个可以指定client实例对应的url

Here is to register him to the server side just started:
Insert picture description here

High availability

Two eurekas should be registered like this:
Insert picture description here
three eurekas:
Insert picture description here
multiple registrations:
Insert picture description here
direct comma separated

Published 56 original articles · Like1 · Visits1509

Guess you like

Origin blog.csdn.net/weixin_44841849/article/details/105404518