I have an issue to call some urls from api gateway to one microservices. Two urls shown below are not working and it throws 404 Not Found error.
http://localhost:8765/currency-conversion/currency-conversion/from/USD/to/INR/quantity/10
http://localhost:8765/currency-conversion/currency-conversion-feign/from/USD/to/INR/quantity/10
Here is the application properties file of api gateway
spring.application.name=api-gateway
server.port=8765
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
eureka.instance.hostname=localhost
# http://localhost:8765/CURRENCY-CONVERSION/currency-conversion/from/USD/to/INR/quantity/10 (Working)
# http://localhost:8765/CURRENCY-CONVERSION/currency-conversion-feign/from/USD/to/INR/quantity/10 (Working)
spring.cloud.gateway.discovery.locator.enabled=true
# http://localhost:8765/currency-conversion/currency-conversion/from/USD/to/INR/quantity/10 (Not Working)
# http://localhost:8765/currency-conversion/currency-conversion-feign/from/USD/to/INR/quantity/10 (Not Working)
spring.cloud.gateway.discovery.locator.lower-case-service-id=true
Here is the application properties file of currency-conversion-service
spring.config.import=optional:configserver:http://localhost:8888
spring.application.name=currency-conversion
server.port=8100
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
eureka.instance.hostname=localhost
Here is the controller class of currency-conversion-service
@RestController
public class CurrencyConversionController {
@GetMapping("/currency-conversion/from/{from}/to/{to}/quantity/{quantity}")
public CurrencyConversion calculateCurrencyConversion(
@PathVariable String from,
@PathVariable String to,
@PathVariable BigDecimal quantity
) {
}
@GetMapping("/currency-conversion-feign/from/{from}/to/{to}/quantity/{quantity}")
public CurrencyConversion calculateCurrencyConversionFeign(
@PathVariable String from,
@PathVariable String to,
@PathVariable BigDecimal quantity
) {
}
}
How can I fix it?
I believe you should have the property as follows:
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true
So no dashes but camel case.