

當訪問http://localhost:8080/nacos-provider-auth/test 時報404錯誤
這里處理方法有兩種
1.在目標應用添加 context-path
server: port: 8081 servlet: context-path: "/nacos-provider-auth"
2.去掉訪問前綴 StripPrefix, 例如,StripPrefix=1請求/nacos-provider-auth/test,去除掉前面一個前綴之后,最后轉發到目標服務的路徑為/test
spring: application: name: nacos-provider-gateway cloud: nacos: discovery: server-addr: 127.0.0.1:8848 gateway: discovery: locator: lower-case-service-id: true #將請求路徑上的服務名配置為小寫(因為服務注冊的時候,向注冊中心注冊時將服務名轉成大寫的了,比如以/service-hi/*的請求路徑被路由轉發到服務名為service-hi的服務上 enabled: false #表明gateway開啟服務注冊和發現的功能,並且spring cloud gateway自動根據服務發現為每一個服務創建了一個router,# 這個router將以服務名開頭的請求路徑轉發到對應的服務 routes: - id: nacos-provider-auth uri: lb://nacos-provider-auth order: -1 predicates: - Path=/nacos-provider-auth/** filters: - StripPrefix=1
