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

发布于 2022-09-13 00:20:47 字数 1538 浏览 14 评论 0

第一部分:
这是我的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).

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2022-09-20 00:20:47

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文