项目完整例子传送门
项目用到模块:
Spring Cloud中Eureka高可用集群介绍:
Eureka单点注册的模式叫做Standalone Mode
单机模式
Eureka集群叫做Peer Awareness
对等模式 , 每一个Eureka Server 身份都是对等的,相互注册形成集群,同步注册信息
创建eureka-server-peer-awareness子项目
- pom.xml同单机版Eureka Server,单机版项目传送门
- 启动类中,标识
@EnableEurekaServer
,表明是注册中心
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerPeerAwarenessApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerPeerAwarenessApplication.class, args);
}
}
- application.yml中配置,这里使用同一配置文件分段配置,属于spring-boot配置文件中用法,这里是参照官方配置的三台实例,将peer1&