Spring Cloud (iii): Construction of Eureka Services

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.