From 1785c11120012aac9276dedb588943b65990ecbc Mon Sep 17 00:00:00 2001 From: Hligaty <1970316213@qq.com> Date: Wed, 20 Sep 2023 22:29:30 +0800 Subject: [PATCH 1/3] Refactoring:optimize the order and condition matching of service registration automatic configuration. --- .../PolarisServiceRegistryAutoConfiguration.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistryAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistryAutoConfiguration.java index 7a94378fb..1cf7a83a9 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistryAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistryAutoConfiguration.java @@ -31,14 +31,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; -import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; +import org.springframework.cloud.client.serviceregistry.ServiceRegistryAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -49,10 +49,10 @@ */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties +@ConditionalOnBean(AutoServiceRegistrationProperties.class) @ConditionalOnPolarisRegisterEnabled -@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) -@AutoConfigureAfter({AutoServiceRegistrationConfiguration.class, AutoServiceRegistrationAutoConfiguration.class, - PolarisDiscoveryAutoConfiguration.class}) +@AutoConfigureBefore(ServiceRegistryAutoConfiguration.class) +@AutoConfigureAfter({AutoServiceRegistrationAutoConfiguration.class, PolarisDiscoveryAutoConfiguration.class}) public class PolarisServiceRegistryAutoConfiguration { @Bean @@ -65,7 +65,6 @@ public PolarisServiceRegistry polarisServiceRegistry( } @Bean - @ConditionalOnBean(AutoServiceRegistrationProperties.class) public PolarisRegistration polarisRegistration( PolarisDiscoveryProperties polarisDiscoveryProperties, PolarisContextProperties polarisContextProperties, @@ -81,7 +80,6 @@ public PolarisRegistration polarisRegistration( } @Bean - @ConditionalOnBean(AutoServiceRegistrationProperties.class) public PolarisAutoServiceRegistration polarisAutoServiceRegistration( PolarisServiceRegistry registry, AutoServiceRegistrationProperties autoServiceRegistrationProperties, From 535c50e821d230c3d8d57000863b1d5e33f0e16c Mon Sep 17 00:00:00 2001 From: Hligaty <1970316213@qq.com> Date: Thu, 21 Sep 2023 20:11:04 +0800 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73987311a..e0781d1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ - [fix:the polaris config relation non-daemon thread should stop when application fails to start.](https://github.com/Tencent/spring-cloud-tencent/pull/1102) - [Refactoring:remove invalid @AutoConfigureAfter and @AutoConfigureBefore from discovery client automatic configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1116) - [fix:fix feign url bug when using sleuth.](https://github.com/Tencent/spring-cloud-tencent/pull/1120) +- [refactor:optimize the order and condition matching of service registration automatic configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1129) From 0f6b3d2448fb33aedb303eb841cd660da11d2ce9 Mon Sep 17 00:00:00 2001 From: Hligaty <1970316213@qq.com> Date: Fri, 22 Sep 2023 10:43:11 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0781d1aa..99186fd61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,4 @@ - [fix:the polaris config relation non-daemon thread should stop when application fails to start.](https://github.com/Tencent/spring-cloud-tencent/pull/1102) - [Refactoring:remove invalid @AutoConfigureAfter and @AutoConfigureBefore from discovery client automatic configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1116) - [fix:fix feign url bug when using sleuth.](https://github.com/Tencent/spring-cloud-tencent/pull/1120) -- [refactor:optimize the order and condition matching of service registration automatic configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1129) +- [refactor:optimize the order and condition matching of service registration automatic configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1131)