Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix

In the previous tutorial, I introduced you to the Eureka Server to allow services in a Microservices system can register and search for each other. In this tutorial, I will show you how services can be registered with Eureka Server using Eureka Client, with Spring Cloud Netflix.

As an example of this tutorial, I will be using the Eureka Server that I created using Spring Cloud Netflix in my previous post. The UI of Eureka Server is as follows:

Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix

Now, I will create a service using Spring Boot project that uses the Eureka Client and Web dependencies as follows:

Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix

Result:

Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix

To register this service with Eureka Server, we have 3 steps to do:

First of all you need to declare our application as an Eureka Client first.

To do this, declare annotation @EnableEurekaClient to the main class of the application.

The second step, we need to do is declare the Eureka Server information in the Spring Boot application.properties configuration file.

We will declare the eureka.client.service-url.default-zone property with the URL value that points to the Eureka Server as follows:

The last step is to identify our service with other services, you need to name our application.

We will use the spring.application.name property and declare it in the configuration file of the application, application.properties, to do this.

At this point, if you start our application and access the Eureka Server, you will see the following result:

Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix

As you can see, in the “Instances currently registered with Eureka” section, the application which we just created, has registered with Eureka Server and is ready for other services to find it.

Register services with Eureka Server using Eureka Client, with Spring Cloud Netflix
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
4Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.