From c45b04ff4f406388ebe673ad305b92a7d64e2b67 Mon Sep 17 00:00:00 2001 From: Fishtail <49390359+fuyuwei01@users.noreply.github.com> Date: Wed, 14 Aug 2024 11:05:40 +0800 Subject: [PATCH] fix:fix nearby router properties loading bug. (#1381) Co-authored-by: Haotian Zhang --- CHANGELOG.md | 1 + .../cloud/polaris/router/config/RouterAutoConfiguration.java | 2 -- .../router/config/RouterConfigModifierAutoConfiguration.java | 4 ++++ .../polaris/router/config/FeignAutoConfigurationTest.java | 1 + .../polaris/router/config/RouterAutoConfigurationTests.java | 1 + spring-cloud-tencent-dependencies/pom.xml | 2 +- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6a498136..7babdd8ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,3 +9,4 @@ - [feat: support lane router](https://github.com/Tencent/spring-cloud-tencent/pull/1378) - [feat: add lane router examples](https://github.com/Tencent/spring-cloud-tencent/pull/1379) - [fix: fix the lossless provider override in multiple registries scenario](https://github.com/Tencent/spring-cloud-tencent/pull/1380) +- [fix:fix nearby router properties loading bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1381) diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterAutoConfiguration.java index e2f38f556..9cc2d14a1 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterAutoConfiguration.java @@ -45,7 +45,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.core.annotation.Order; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.web.client.RestTemplate; @@ -60,7 +59,6 @@ import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE; @Configuration(proxyBeanMethods = false) @ConditionalOnPolarisRouterEnabled @LoadBalancerClients(defaultConfiguration = LoadBalancerConfiguration.class) -@Import({PolarisNearByRouterProperties.class, PolarisMetadataRouterProperties.class, PolarisRuleBasedRouterProperties.class}) public class RouterAutoConfiguration { @Bean diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterConfigModifierAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterConfigModifierAutoConfiguration.java index 782135dcb..e1de4a37f 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterConfigModifierAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/RouterConfigModifierAutoConfiguration.java @@ -19,11 +19,14 @@ package com.tencent.cloud.polaris.router.config; import com.tencent.cloud.polaris.router.RouterConfigModifier; +import com.tencent.cloud.polaris.router.config.properties.PolarisMetadataRouterProperties; import com.tencent.cloud.polaris.router.config.properties.PolarisNearByRouterProperties; +import com.tencent.cloud.polaris.router.config.properties.PolarisRuleBasedRouterProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; /** * RouterConfigModifierAutoConfiguration. @@ -32,6 +35,7 @@ import org.springframework.context.annotation.Configuration; */ @Configuration(proxyBeanMethods = false) @ConditionalOnPolarisRouterEnabled +@Import({PolarisNearByRouterProperties.class, PolarisMetadataRouterProperties.class, PolarisRuleBasedRouterProperties.class}) public class RouterConfigModifierAutoConfiguration { @Bean diff --git a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/FeignAutoConfigurationTest.java b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/FeignAutoConfigurationTest.java index 774ca3acc..b76bb7799 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/FeignAutoConfigurationTest.java +++ b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/FeignAutoConfigurationTest.java @@ -39,6 +39,7 @@ public class FeignAutoConfigurationTest { .withConfiguration(AutoConfigurations.of( MetadataAutoConfiguration.class, RouterAutoConfiguration.class, + RouterConfigModifierAutoConfiguration.class, PolarisContextAutoConfiguration.class, FeignAutoConfiguration.class, ApplicationContextAwareUtils.class diff --git a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/RouterAutoConfigurationTests.java b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/RouterAutoConfigurationTests.java index a27c9e7cd..c2bb33735 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/RouterAutoConfigurationTests.java +++ b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/RouterAutoConfigurationTests.java @@ -42,6 +42,7 @@ public class RouterAutoConfigurationTests { TestRestTemplatesConfiguration.class, MetadataAutoConfiguration.class, RouterAutoConfiguration.class, + RouterConfigModifierAutoConfiguration.class, RouterBootstrapAutoConfiguration.class, PolarisContextAutoConfiguration.class, RouterAutoConfiguration.RouterLabelRestTemplateConfig.class, diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 8e2487dda..917d3d2bb 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -74,7 +74,7 @@ 1.14.0-2020.0.6-SNAPSHOT - 1.15.4-SNAPSHOT + 1.15.5-SNAPSHOT 32.0.1-jre