Search code examples
javahttpexceptionmicroservicesspring-cloud

404 Not Found while making HTTP GET request


I m making basic microservice project . I have two services one of them user other one is reservation service. I ve registered them to eureka server which is currently visible on eureka and added gateway. User service working fine with gateway but When I call the reservation service I got 404 Not Found error. user service and reservation service configurations are same. Why i am getting this error message and how can i solve that problem , I m sending request like this http://localhost:9000/reservation/reservation

API GATEWAY CONFIGURATION

server.port= 9000
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/
spring.application.name=api-gateway
spring.cloud.gateway.routes[0].id = user-service
spring.cloud.gateway.routes[0].uri = lb://user-service
spring.cloud.gateway.routes[0].predicates=Path=/user/**
spring.cloud.gateway.routes[1].id = reservation-service
spring.cloud.gateway.routes[1].uri = lb://reservation-service
spring.cloud.gateway.routes[1].predicates=Path=/reservation/**
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

Reservation Service Configuration

server.port=8082
spring.application.name=reservation-service
eureka.client.register-with-eureka= true
euraka.client.fetch.registry = true
eureka.client.service-url.defaultzone = http://localhost:8761/eureka
spring.datasource.url=jdbc:mysql://localhost:3306/projectschema
spring.datasource.username=root
spring.datasource.password=12345678Aa
spring.jpa.generate-ddl=true
spring.jpa.defer-datasource-initialization=true
spring.jpa.hibernate.ddl-auto= update
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Reservation Service Controller

 @RestController
@RequestMapping("reservation")
  public class ReservationController {
  @Autowired
  ReservationService reservationService;

@GetMapping("/reservation")
public String GenerateReservation(){
  return "helo";
}

}


Solution

  • I moved all packages under the same package and it worked.