Category: spring_boot
Eureka Client
Published on 22 Aug 2026
Explanation
After creating the Eureka Server, each Spring Boot microservice can register itself as a Eureka Client. This allows Eureka to maintain a registry of available services.
Code:
Eureka Server
:8761
▲
register│
┌──────────────┼──────────────┐
│ │ │
User Service Order Service Payment Service
:8081 :8082 :8083
Explanation
Add the Eureka Client dependency to the Spring Boot microservice. Spring Cloud Netflix Eureka Client provides the functionality required to register the service with Eureka.
Code:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
Explanation
Configure the microservice name and Eureka Server URL in application.properties. The service name is important because other microservices can use it to discover this service.
Code:
spring.application.name=user-service server.port=8081 eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
Explanation
The Eureka Client automatically registers the Spring Boot application with Eureka when the application starts. In modern Spring Cloud versions, explicit @EnableEurekaClient is generally not required when the Eureka Client dependency is present.
Code:
@SpringBootApplication
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(
UserServiceApplication.class,
args
);
}
}
Explanation
Start the Eureka Server first and then start the microservices. Each service registers its application name, host, port, and availability information with Eureka.
Code:
Start Eureka Server
↓
http://localhost:8761
↓
Start User Service
↓
Start Order Service
↓
Eureka Registry
├── USER-SERVICE :8081
└── ORDER-SERVICE :8082
Explanation
Once the services are registered, open the Eureka dashboard to verify them. The registered services appear under the Instances currently registered with Eureka section.
Code:
Eureka Dashboard Instances currently registered: USER-SERVICE UP (1) ORDER-SERVICE UP (1) UP = Service is available