Setting up Spring Cloud Gateway
Setting up Spring Cloud Gateway as an edge server is straightforward and can be done with the following steps:
- Create a Spring Boot project using Spring Initializr, as described in Chapter 3, Creating a Set of Cooperating Microservices – refer to the Using Spring Initializr to generate skeleton code section.
- Add a dependency on
spring-cloud-starter-gateway-server-webflux
. - To be able to locate microservice instances through Netflix Eureka, also add the
spring-cloud-starter-netflix-eureka-client
dependency. - Add the edge server project to the common build file,
settings.gradle
:include ':spring-cloud:gateway'
- Add a
Dockerfile
with the same content as for the microservices; see theDockerfile
content in the$BOOK_HOME/Chapter10/microservices
folder. - Add the edge server to our three Docker Compose files:
gateway: environment: - SPRING_PROFILES_ACTIVE=docker build: spring...