Code examples of setting up a REST service
Before we can create a REST service based on Spring WebFlux, we need to add Spring WebFlux (and the dependencies that Spring WebFlux requires) to the classpath for Spring Boot to be detected and configured during startup. Spring Boot provides a large number of convenient starter dependencies that bring in a specific feature, together with the dependencies each feature normally requires. So, let’s use the starter dependency for Spring WebFlux and then see what a simple REST service looks like!
Starter dependencies
In this book, we will use Gradle as our build tool, so the Spring WebFlux starter dependency will be added to the build.gradle
file. It looks like this:
implementation('org.springframework.boot:spring-boot-starter-webflux')
You might be wondering why we don’t specify a version number. We will talk about that when we look at a complete example in Chapter 3, Creating a Set of Cooperating Microservices!
When...