1. Concept: Eureka-Cloud service discovery, a REST-based service for locating services to enable mid-cloud service discovery and failover.
2, Build: A, first of all, the next stand-alone construction, the first new MAVEN project, in the POM import Eureka coordinates:
<dependencies>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
</dependencies>
B, New class Eurekaapplication
@SpringBootApplication
@EnableEurekaServer
public class Eurekaapplication {
public static void Main (string[] args) {
Springapplication.run (Eurekaapplication.class, args);
}
}
Where @enableeurekaserver, start a service registry to provide conversations for other apps
C, application.properties configuration items
# The default port server.port=8761
Eureka.client.register-with-eureka=false
Eureka.client.fetch-registry=false
eureka.client.serviceurl.defaultzone=http://localhost:${server.port}/eureka/
D, start springboot, and Access http://localhost:8761/
3, the above is only a single-machine mode environment, the business environment is often high-availability (HA) environment, this time to consider the cluster, a node hangs, there is another node, cluster we just change the configuration file can be
eureka.client.serviceurl.defaultzone=http://localhost:8762/eureka/;http://localhost:8763/eureka/; If IP is different, configure three nodes , you need three machines
Spring Cloud (iii): Construction of Eureka Services