12.1 How to Include Eureka Server
pom.xml引入
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>12.2 How to Run a Eureka Server
启动类
@SpringBootApplication @EnableEurekaServer public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).web(true).run(args); } }
12.4 Standalone Mode(单一模式)
server: port: 8761 eureka: instance: hostname: localhost client: registerWithEureka: false #是否注册到别的eureka fetchRegistry: false #是否要合并到别的eureka中去 serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/12.5. Peer Awareness(对等意识)
--- spring: profiles: peer1 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2/eureka/ --- spring: profiles: peer2 eureka: instance: hostname: peer2 client: serviceUrl: defaultZone: http://peer1/eureka/