我在将一些URL从API网关调用到一个微服务时遇到了问题。下面显示的两个URL不起作用,并抛出404未找到错误。
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
这里是API网关的应用属性文件
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
以下是货币转换-服务的应用程序属性文件
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
以下是货币兑换服务的控制器类
@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
) {
}
}
我怎么才能修好它?
2条答案
按热度按时间jljoyd4f1#
我更改了微服务的名称,如下所示,它起作用了
从…
Spring.applation.name=货币兑换
至
Spring.applation.name=货币兑换-毫秒
从…
Spring.Applation.name=货币兑换
至
Spring.application.name=currency-conversion-ms
aelbi1ox2#
我认为你应该拥有如下财产:
所以没有破折号,只有 Camel 的箱子。