A simple project using Spring Boot 3 to illustrate how to use Spring Cloud Gateway to route requests to downstream services and Eureka service registry.
- Java 17
- Gradle 7.4 or greater
- Postman
./gradlew eureka-server:bootRun
./gradlew api-gateway:bootRun
./gradlew test-customer-service:bootRun
./gradlew test-invoice-service:bootRun
The services are configured to run on the following ports:
- Gateway : 8080
- Eureka : 8083
- Invoice Service : 8081
- Customer Service : 8082
To test if the gateway is working as expected use postman to access the routes defined in the individual services
via the gateways service url localhost:8080
To see which routes are registered on the gateway navigate to http://localhost:8080/actuator/gateway/routes
To see which routes are registered on the Eureka registry service to http://localhost:8083/
A postman collection is included for testing the various routes.
If you receive and error like
Could not open init generic class cache for initialization script
Then go into settings; Build, Execution, Deployment > Build Tools > Gradle. Then select the module and set Use Gradle from
to Specified location
and set the location of gradle.
For further reference, please consider the following sections:
The following guides illustrate how to use some features concretely: