The document is as follows:
2.8. Disabling Ribbon with Eureka Server and Client starters
spring-cloud-starter-netflix-eureka-server and spring-cloud-starter-netflix-eureka-client come along with a spring-cloud-starter-netflix-ribbon. Since Ribbon load-balancer is now in maintenance mode, we suggest switching to using the Spring Cloud LoadBalancer, also included in Eureka starters, instead.
In order to that, you can set the value of spring.cloud.loadbalancer.ribbon.enabled property to false.
You can then also exclude ribbon-related dependencies from Eureka starters in your build files, like so:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</exclusion>
<exclusion>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-eureka</artifactId>
</exclusion>
</exclusions>
</dependency>
The documentation states that two ways to disable ribbon are to enable OnNoRibbonDefaultCondition. code show as below :
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RestTemplate.class)
@Conditional(OnNoRibbonDefaultCondition.class)
protected static class BlockingLoadbalancerClientConfig {
@Bean
@ConditionalOnBean(LoadBalancerClientFactory.class)
@Primary
public BlockingLoadBalancerClient blockingLoadBalancerClient(
LoadBalancerClientFactory loadBalancerClientFactory) {
return new BlockingLoadBalancerClient(loadBalancerClientFactory);
}
}
private static final class OnNoRibbonDefaultCondition extends AnyNestedCondition {
private OnNoRibbonDefaultCondition() {
super(ConfigurationPhase.REGISTER_BEAN);
}
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.ribbon.enabled",
havingValue = "false")
static class RibbonNotEnabled {
}
@ConditionalOnMissingClass("org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient")
static class RibbonLoadBalancerNotPresent {
}
}
Class as a judgment condition: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient is defined inspring-cloud-netflix-ribbon, spring-cloud-starter-netflix-archaius also depends onspring-cloud-netflix-ribbon, spring-cloud-starter-netflix-eureka-client depends onspring-cloud-netflix-ribbon.
So only Excluding spring-cloud-starter-ribbon is not enough.
Comment From: OlgaMaciaszek
Hello, @lanmolsz Thanks for reporting this. Yes, you actually need to exclude that from wherever it's used so that it's no longer in the classpath. Thought that was understandable, but state it there more explicitly.
Comment From: OlgaMaciaszek
Have looked at it in the doc: it actually sais: You can then also exclude ribbon-related dependencies from Eureka starters meaning that you can also exclude them after disabling with the flag if you like. So it's correct. Will leave it as is.