diff --git a/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerAutoConfiguration.java b/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerAutoConfiguration.java index 14a7bc181..974ad2cf1 100644 --- a/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerAutoConfiguration.java +++ b/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/ReactiveSentinelCircuitBreakerAutoConfiguration.java @@ -24,6 +24,7 @@ import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.circuitbreaker.Customizer; import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory; import org.springframework.context.annotation.Bean; @@ -35,6 +36,8 @@ import org.springframework.context.annotation.Configuration; @Configuration @ConditionalOnClass( name = { "reactor.core.publisher.Mono", "reactor.core.publisher.Flux" }) +@ConditionalOnProperty(name = "spring.cloud.circuitbreaker.sentinel.enabled", + havingValue = "true", matchIfMissing = true) public class ReactiveSentinelCircuitBreakerAutoConfiguration { @Bean diff --git a/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerAutoConfiguration.java b/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerAutoConfiguration.java index 2d22ba077..d4b373253 100644 --- a/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerAutoConfiguration.java +++ b/spring-cloud-circuitbreaker-sentinel/src/main/java/com/alibaba/cloud/circuitbreaker/sentinel/SentinelCircuitBreakerAutoConfiguration.java @@ -26,6 +26,7 @@ import com.alibaba.csp.sentinel.SphU; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; import org.springframework.cloud.client.circuitbreaker.Customizer; import org.springframework.context.annotation.Bean; @@ -38,6 +39,8 @@ import org.springframework.context.annotation.Configuration; */ @Configuration @ConditionalOnClass({ SphU.class }) +@ConditionalOnProperty(name = "spring.cloud.circuitbreaker.sentinel.enabled", + havingValue = "true", matchIfMissing = true) public class SentinelCircuitBreakerAutoConfiguration { @Bean diff --git a/spring-cloud-circuitbreaker-sentinel/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-circuitbreaker-sentinel/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 000000000..44597a6d6 --- /dev/null +++ b/spring-cloud-circuitbreaker-sentinel/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,7 @@ +{"properties": [ + { + "name": "spring.cloud.circuitbreaker.sentinel.enabled", + "type": "java.lang.Boolean", + "description": "enable sentinel circuitbreaker or not." + } +]}