spring:
application:
name: ms-registry-ha
---
spring:
profiles: peer1
server:
port: 8081
eureka:
client:
serviceUrl:
#关键的就是这个:互相注册EurekaServer的地址
defaultZone: http://localhost:8082/eureka
---
spring:
profiles: peer2
server:
port: 8082
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8081/eureka
打包运行:
java -jar ms-registry-ha-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer1
java -jar ms-registry-ha-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer2
服务提供方和消费方可以注册多个,也可以只注册其中一个,然后Server之间会相互复制:
eureka.client.serviceUrl.defaultZone=http://localhost:8081/eureka, http://localhost:8082/eureka
网友评论