SpringCloud Gatway 不起作用,总是不路由,报404

路由不起作用的集中情况:

配置如下:

spring:
  application:
    name: gateway
  cloud:
    gateway:
      routes:
      - id: cruder_route
        uri: http://localhost:19602/
        predicates:
        - Path=/crud/**
        filters:
        - StripPrefix=1

      - id: cruder_static
        uri: http://localhost:19602/
        predicates:
        - Path=/static/**,/cruder/**,/view/**,/vue/**,/objectRel/**,/interface/**,/manage/**,/admin/**
      - id: gate
        uri: http://localhost:9000/
        predicates:
        - Path=/gate/**,
      - id: spider_route
        uri: http://localhost:19603/
        predicates:
        - Path=/spider/**,

标红的部分:

1、目标路径和断言部分,跟zuul的方式不一,没有自动清除前缀。虽有要配置:过滤器,脱掉前缀。

filters:
        - StripPrefix=1

2、断言中,Path配置的后面加上逗号。这种情况,在第一个配置中生效,但是在后续的就不生效了。加上逗号就可以了。

以上是我解决路由不工作的问题的处理方式。

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值