diff --git a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java index a567fe84..118382fa 100644 --- a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java +++ b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java @@ -264,6 +264,7 @@ public class GatewayAutoConfiguration { @Bean @ConditionalOnClass(name = "org.springframework.cloud.client.discovery.event.HeartbeatMonitor") + @ConditionalOnProperty(prefix = GatewayProperties.PREFIX, name = ".route-refresh-listener.enabled", matchIfMissing = true) public RouteRefreshListener routeRefreshListener(ApplicationEventPublisher publisher) { return new RouteRefreshListener(publisher); } diff --git a/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json index d4fc0a54..58297083 100644 --- a/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -424,6 +424,12 @@ "type": "java.lang.Boolean", "description": "Include the port in matching the host name.", "defaultValue": "true" + }, + { + "name": "spring.cloud.gateway.route-refresh-listener.enabled", + "type": "java.lang.Boolean", + "description": "If RouteRefreshListener should be turned on.", + "defaultValue": "true" } ] }