加了个网关gateway,访问网关端口,却访问不到内容

第一部分:
这是我的gateway网关yaml配置:
server:
port: 9727

spring:
application:

name: cloud-gateway

cloud:

geteway:
  routes:
    - id: payment_routh
      uri: http://localhost:8001
      predicates:
        - Path=/payment/get/**

    - id: payment_routh2
      uri: http://localhost:8001
      predicates:
        - Path=/payment/lb/**

eureka:
instance:

hostname: cloud-gateway-service

client:

fetch-registry: true
register-with-eureka: true
service-url:
  defaultZone: http://eureka7001.com:7001/eureka/
  

第二部分:
这是我的另一个服务提供者的内容:(Controller)
@GetMapping("/payment/get/{id}")

public CommonResult getPaymentById(@PathVariable("id") int id) {
    Payment payment = paymentService.getPaymentById(id);
    log.info("查询结果:" + payment);
    if (payment != null) {
        return new CommonResult(200, "查询成功,port:"+port, payment);
    } else {
        return new CommonResult(444, "查询失败,port"+port, null);
    }
}

第三部分:
开始访问:(不经过网关访问可以得到数据:地址是:http://http://localhost:8001/payment/get/3,可以得到数据)
但是经过网关访问(地址是:http://http://localhost:9727/payment/get/3),却返回错误:

Whitelabel Error Page
This application has no configured error view, so you are seeing this as a fallback.

Wed Jun 23 16:55:58 CST 2021
[7beaa06d-1] There was an unexpected error (type=Not Found, status=404).

不知道为啥会出现这样的问题??

阅读 8.8k
1 个回答

问题解决了,把gateway写成了geteway了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题