ARTICLE AD BOX
I'm attempting to test Reactive Gateway using simple Spring Cloud static routing with a couple of basic services generated from Spring Boot 4.0.1 (Spring Cloud 2025.1.0) using Java 25. I keep getting a 404 error when attempting to access a service via the Spring Cloud Gateway.
I have generated the following.Firstly, a service that returns a hardcoded string:
package com.test.serviceplay.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/play") public class PlayController { @GetMapping("/{id}") public ResponseEntity<String> playGet(@PathVariable Long id){ return ResponseEntity.ok("Play GET called"); } }Its only dependency is spring-boot-starter-webmvc
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webmvc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webmvc-test</artifactId> <scope>test</scope> </dependency> </dependencies>Secondly, a basic Reactive Gateway service
pom.xml snippet:
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway-server-webflux</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-test</artifactId> <scope>test</scope> </dependency> </dependencies>application.yml
spring: application: name: gateway-play cloud: gateway: routes: - id: service-play uri: http://localhost:8080 predicates: - Path=/api/play/** server: port: 9191I can access the service directly on its own port http://localhost:8080/api/play/1, but trying to do so using the gateway on port 9191 (http://localhost:9191/api/play/1) results in a 404 error.
Any help would be much appreciated.
