How to do it...

Let us implement client-side load balancing by following these steps:

  1. First, create a Maven project ch10-eureka-client that contains pom.xml with SpringCloudFinchley dependencies. Just add the core starter POM such as webflux, the actuator and the following SpringCloudNetflixRibbon module dependencies:
<dependency> 
   <groupId>org.springframework.cloud</groupId> 
   <artifactId>spring-cloud-starter-eureka</artifactId> 
</dependency> 
<dependency>   
   <groupId>org.springframework.cloud</groupId> 
   <artifactId>spring-cloud-starter-ribbon</artifactId> 
</dependency> 
  1. Then, create a typical bootstrap class suited for a Eureka client that fetches the registry and automatically registers itself to the Eureka server:
@SpringBootApplication @EnableDiscoveryClient ...

Get Spring 5.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.