Próbuje zestawic proste połączenie między API Gatewayem i jakimś serwisem, które powinny się widzieć przez Eureke.
Mam więc prosty serwis
@SpringBootApplication
@EnableEurekaClient
@RestController
@RequestMapping("/api")
public class QuestionServiceApplication {
public static void main(String[] args) {
SpringApplication.run(QuestionServiceApplication.class, args);
}
@GetMapping("/hello")
ResponseEntity<String> hello() {
return ResponseEntity.ok("Hello world");
}
}
Z taką konfiguracją
spring:
application:
name: question-service
server:
port: 8081
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
No i oczywiście mam też Eureke
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
I na końcu, API Gateway
@SpringBootApplication
@EnableEurekaClient
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
Który ma o taką konfigurację
server:
port: 8080
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
spring:
application:
name: gateway
cloud:
gateway:
routes:
- id: questionService
uri: lb://question-service
predicates:
- Path=/question-service/**
W Eurece wszystko wygląda ok
A request na http://localhost:8081/api/hello
zwraca mi pięknego Hello Worlda
Problem w tym, że przy strzale pod http://localhost:8080/question-service/api/hello
, dostaje HTTP 404
Czego i gdzie brakuje? W żadnym z serwisów nie ma żadnego loga który by mówił co jest nie tak