Spring Cloud Gateway doesn't find the microservices (Not found 404 error)
13:27 04 Aug 2021

I have this simple microservices application with Spring Boot and I try to add the Spring Cloud Gateway service, but it doesn't work. All microservices, including the Eureka server, work well, but when I try to access to some microservice using the Gateway route, it doesn't find the microservice.

ApiGateway pom.xml



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.5.3
         
    
    com.futurex.microservices
    APIGateway
    0.0.1-SNAPSHOT
    APIGateway
    Demo project for Spring Boot
    
        1.8
        2020.0.3
    
    

        
            org.springframework.cloud
            spring-cloud-starter-gateway
        
        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-client
        
        
            org.springframework.boot
            spring-boot-starter-actuator
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    
    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


API Gateway application.yml

spring:
  application:
    name: API-GATEWAY
  cloud:
    gateway:
      routes:
        - id: FX-SERVICE1
          uri: http://localhost:8005
          predicates:
            - Path=/fx-service1/**
        - id: FX-SERVICE2
          uri: http://localhost:8006
          predicates:
            - Path=/fx-service2/**
    discovery:
      enabled: true
    config:
      uri: http://localhost:8081
server:
  port: 8081
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
    register-with-eureka: true
    fetch-registry: true
  instance:
    hostname: localhost

API Gateway main

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

@SpringBootApplication
@EnableEurekaClient
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }


}

Api Gateway Not found 404 error

java spring spring-boot gateway spring-cloud-gateway