From 4e024319302c24d9eb30b1965200fd1b13f18d97 Mon Sep 17 00:00:00 2001 From: Fishtail <49390359+fuyuwei01@users.noreply.github.com> Date: Mon, 27 Jul 2026 15:15:58 +0800 Subject: [PATCH] fix: fix route failure caused by Spring Cloud Gateway 5.x property prefix change (#1811) --- CHANGELOG.md | 1 + .../src/main/resources/application.yml | 40 ++++++------- .../src/main/resources/application.yml | 17 +++--- .../src/main/resources/application.yml | 56 ++++++++++--------- .../msgw-scg/src/main/resources/bootstrap.yml | 18 +++--- 5 files changed, 70 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9b4af45b..014c0005b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,3 +12,4 @@ - [fix: prepend context-path to contract reporter API paths](https://github.com/Tencent/spring-cloud-tencent/pull/1803) - [feat: support overrideHost configuration for ratelimit, event reporter and stat modules](https://github.com/Tencent/spring-cloud-tencent/pull/1804) - [fix: split contract base-package for springdoc scan](https://github.com/Tencent/spring-cloud-tencent/pull/1807) +- [fix: fix route failure caused by Spring Cloud Gateway 5.x property prefix change](https://github.com/Tencent/spring-cloud-tencent/pull/1811) \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-router-grayrelease-lane-example/router-grayrelease-lane-gateway/src/main/resources/application.yml b/spring-cloud-tencent-examples/polaris-router-grayrelease-lane-example/router-grayrelease-lane-gateway/src/main/resources/application.yml index ceff4d9e0..dc599f380 100644 --- a/spring-cloud-tencent-examples/polaris-router-grayrelease-lane-example/router-grayrelease-lane-gateway/src/main/resources/application.yml +++ b/spring-cloud-tencent-examples/polaris-router-grayrelease-lane-example/router-grayrelease-lane-gateway/src/main/resources/application.yml @@ -19,22 +19,24 @@ spring: stat: enabled: true gateway: - discovery: - locator: - enabled: true - 'predicates[0]': - name: Path - args: - patterns: '''/'' + serviceId + ''/**''' - 'filters[0]': - name: RewritePath - args: - regexp: '''/'' + serviceId + ''/(?.*)''' - replacement: '''/$\{remaining}''' - routes: - - id: LaneRouterCallerService - uri: lb://LaneCallerService - predicates: - - Path=/LaneCallerService/** - filters: - - StripPrefix=1 + server: + webflux: + discovery: + locator: + enabled: true + 'predicates[0]': + name: Path + args: + patterns: '''/'' + serviceId + ''/**''' + 'filters[0]': + name: RewritePath + args: + regexp: '''/'' + serviceId + ''/(?.*)''' + replacement: '''/$\{remaining}''' + routes: + - id: LaneRouterCallerService + uri: lb://LaneCallerService + predicates: + - Path=/LaneCallerService/** + filters: + - StripPrefix=1 diff --git a/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-mvc-service/src/main/resources/application.yml b/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-mvc-service/src/main/resources/application.yml index 7a98796f7..61bc2bdcb 100644 --- a/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-mvc-service/src/main/resources/application.yml +++ b/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-mvc-service/src/main/resources/application.yml @@ -18,13 +18,14 @@ spring: enabled: true port: 28085 gateway: - mvc: - routes: - - id: QuickstartCallerService - uri: lb://QuickstartCallerService - predicates: - - Path=/QuickstartCallerService/** - filters: - - StripPrefix=1 + server: + webmvc: + routes: + - id: QuickstartCallerService + uri: lb://QuickstartCallerService + predicates: + - Path=/QuickstartCallerService/** + filters: + - StripPrefix=1 diff --git a/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-service/src/main/resources/application.yml b/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-service/src/main/resources/application.yml index 9550370c0..1dfdc4ba7 100644 --- a/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-service/src/main/resources/application.yml +++ b/spring-cloud-tencent-examples/quickstart-example/quickstart-gateway-service/src/main/resources/application.yml @@ -1,8 +1,8 @@ server: port: 48081 spring: -# profiles: -# active: context + # profiles: + # active: context application: name: QuickStartGatewayService config: @@ -33,31 +33,33 @@ spring: stat: enabled: true gateway: - discovery: - locator: - enabled: true - 'predicates[0]': - name: Path - args: - patterns: '''/'' + serviceId + ''/**''' - 'filters[0]': - name: RewritePath - args: - regexp: '''/'' + serviceId + ''/(?.*)''' - replacement: '''/$\{remaining}''' - routes: - - id: QuickstartCallerService - uri: lb://QuickstartCallerService - predicates: - - Path=/QuickstartCallerService/** - filters: - - StripPrefix=1 - - id: QuickstartCalleeService - uri: lb://QuickstartCalleeService - predicates: - - Path=/QuickstartCalleeService/** - filters: - - StripPrefix=1 + server: + webflux: + discovery: + locator: + enabled: true + 'predicates[0]': + name: Path + args: + patterns: '''/'' + serviceId + ''/**''' + 'filters[0]': + name: RewritePath + args: + regexp: '''/'' + serviceId + ''/(?.*)''' + replacement: '''/$\{remaining}''' + routes: + - id: QuickstartCallerService + uri: lb://QuickstartCallerService + predicates: + - Path=/QuickstartCallerService/** + filters: + - StripPrefix=1 + - id: QuickstartCalleeService + uri: lb://QuickstartCalleeService + predicates: + - Path=/QuickstartCalleeService/** + filters: + - StripPrefix=1 logging: file: name: /sct-demo-logs/${spring.application.name}/root.log diff --git a/spring-cloud-tencent-examples/tsf-example/msgw-scg/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/tsf-example/msgw-scg/src/main/resources/bootstrap.yml index 6f4b1c4c2..3e79b0dff 100644 --- a/spring-cloud-tencent-examples/tsf-example/msgw-scg/src/main/resources/bootstrap.yml +++ b/spring-cloud-tencent-examples/tsf-example/msgw-scg/src/main/resources/bootstrap.yml @@ -7,14 +7,16 @@ spring: name: msgw-scg cloud: gateway: - discovery: - locator: - enabled: true - lower-case-service-id: false - httpclient: - # The connect timeout in millis, the default is 45s. - connectTimeout: 200 - responseTimeout: 10s + server: + webflux: + discovery: + locator: + enabled: true + lower-case-service-id: false + httpclient: + # The connect timeout in millis, the default is 45s. + connectTimeout: 200 + responseTimeout: 10s consul: enabled: true scheme: HTTP