The spring-cloud-starter-netflix-eureka-server dependency turns a Spring Boot application into a Netflix Eureka service registry. Microservices register their network location with it, and other services look those locations up by name instead of using hard-coded URLs. Adding the starter and annotating the application with @EnableEurekaServer is enough to run a registry with a status dashboard.
It is the server half of Eureka. Client applications use spring-cloud-starter-netflix-eureka-client.
The starter brings in the Eureka server libraries, the Spring Cloud Netflix integration, and the web stack the registry needs to serve its REST API and dashboard. You add it through the Spring Cloud BOM so the version matches your Spring Boot version.
Because it is a registry, run it as its own application, separate from your business services.
The two eureka.client settings stop a standalone server from trying to register with itself and fetch its own registry. Open http://localhost:8761 to see the dashboard listing registered instances.
A client needs the Eureka client starter and the location of the registry:
With the client starter on the classpath, the application registers itself under the name ORDERS-SERVICE on startup, sends heartbeats and deregisters on shutdown. Other services can then call it by name, for example with a @FeignClient(name = "orders-service") or a load-balanced RestClient.Builder or WebClient.Builder. Client-side load balancing is provided by Spring Cloud LoadBalancer, which replaced Ribbon.
Eureka favours availability over consistency. When many heartbeats are missed at once, for example during a network problem, the server enters self-preservation mode and stops evicting instances. This avoids removing healthy services, but it can leave dead ones in the registry for a while, so clients should handle failed calls with retries or circuit breakers.
In production run at least two Eureka servers that register with each other (peer awareness). Each server points its defaultZone at the other peers, and clients list all of them:
An open registry lets anyone register a service. Add spring-boot-starter-security, require HTTP Basic credentials and include them in the client URL (http://user:password@host:8761/eureka/). Spring Security's CSRF protection blocks the registry's non-browser POST requests, so you must ignore CSRF for the /eureka/** paths in your SecurityFilterChain.
On Kubernetes, the platform already provides service discovery through Services and DNS, so a separate registry is often unnecessary. Spring Cloud also supports Consul and Zookeeper for discovery, and the Spring Cloud Kubernetes project integrates with native discovery.
The server received fewer heartbeats than expected and stopped evicting instances. It is common in development with few instances, and you can tune it with eureka.server.enable-self-preservation.
@EnableEurekaClient on clients?No. That annotation is no longer required. The client starter registers the application automatically when it is on the classpath.
No. The registry is held in memory and replicated between peers.
The Spring Cloud Netflix Eureka integration is still supported, although most other Netflix components were removed from Spring Cloud.
spring-cloud-starter-netflix-eureka-server provides a ready-made service registry for Spring Cloud microservices. Annotate one application with @EnableEurekaServer, point clients at it with eureka.client.service-url.defaultZone, run peers for availability, secure the endpoints, and consider native platform discovery when you deploy on Kubernetes.