Spring Cloud Eureka Service governance

Source: Internet
Author: User

Services are the core of the micro-service architecture, which is mainly used to automate the registration and discovery of individual microservices instances.

1. Service Registration

In the service governance framework, a registry is typically built, and each service unit registers its own services with the registry, hosting, ports, version numbers, communication protocols, etc.

Additional information informs the Service center that the registry organizes the list of services by service name.

2. Service Discovery

Because of its operation under the Service governance framework, calls between services are not implemented by specifying a specific address instance address, but rather by initiating a request invocation by a service name.

Use spring Cloud Eureka to build a service registration center

<1>. First we create a foundation project through Spring Initializer, named Eureka-server

<2>. Add the following dependencies in the POM

<dependency>     <groupId>org.springframework.cloud</groupId>     <artifactId> Spring-cloud-starter-eureka-server</artifactid>
</dependency>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<3>. Add annotations @EnableEurekaServer start the registration center

@EnableEurekaServer   //  Open Service registration service @SpringBootApplicationPublicclass  eurekaserverapplication {    publicstaticvoid  main (string[] args {        new springapplicationbuilder (eurekaserverapplication).  Class). Web (true). Run (args);    }}

<4>. Add the following configuration in the Application.properties

server.port= 1111eureka.instance.hostname= localhost# does not need to register itself with the registry Eureka.client.register- With-eureka=false# does not need to retrieve service Eureka.client.fetch-registry=false  Eureka.client.serviceUrl.defaultZone= http://${eureka.instance.hostname}:${server.port}/ Eureka

<5>. Start the service and access http://localhost:1111/to see the following Service registration page

Spring Cloud Eureka Service governance

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.