How to Integrate the Eureka In Spring Boot Project for Microservices? – DSDeepak Sharma
What Is Eureka?
Eureka is an application that has two parts or sides, the first one is the eureka Server and the other one is the eureka client. Eureka clients use to getting all the details of the client. For example how many services are running with the spring cloud and what are their status, port, and names?
The Eureka server is used to provide all the details to the end user with all service statuses on one screen. It uses for registering the microservices in spring boot. It is also known as the Discovery server.
To set up the eureka client in your project first you have to set up the spring cloud project to connect your all services. Spring cloud gateway will provide a single endpoint for all different services.
After setup, you need to add the @EnableEurekaClient
In your spring cloud gateway as
Now you need to add the eureka client dependency in the spring cloud gateway project.
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
Add configuration in the application. property file eureka.client.serviceUrl.defaultZone = http://127.0.0.1:9001/eureka
To set up the Eureka server you need to create a new spring boot application. And then add the dependency in pom.xml file
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency>
Now add the configuration in the application. property file server.port=9001
eureka.client.register-with-eureka=false eureka. client.fetch-registry: false
All done you can access your eureka server after starting both applications
Eureka URL will be the spring cloud gateway base URL with port only http://localhost:9001