路由不起作用的集中情況:
配置如下:
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配置的後面加上逗號。這種情況,在第一個配置中生效,但是在後續的就不生效了。加上逗號就可以了。
以上是我解決路由不工作的問題的處理方式。