We're using openfeign client in our spring application:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.0.1</version>
</dependency>
and we're also using netflix zuul:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
the problem now is that netflix-zuul requires spring-cloud-netflix-ribbon as a dependency, which makes the feignclient use the ribbon load balancer which throws an error because it's incompatible with the newest spring version:
org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient cannot be cast to class org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient
.
according to https://cloud.spring.io/spring-cloud-static/spring-cloud-openfeign/2.2.0.RC2/reference/html/ the Spring load balancer should be used:
In order to maintain backward compatibility, is used as the default load-balancer implementation. However, Spring Cloud Netflix Ribbon is now in maintenance mode, so we recommend using Spring Cloud LoadBalancer instead. To do this, set the value of spring.cloud.loadbalancer.ribbon.enabled to false.
So tried to disable ribbon in the configuration yml but it's not working, feignclient is still using ribbon:
spring:
cloud:
loadbalancer:
ribbon:
enabled: false
I found another answer here: https://stackoverflow.com/a/51511614/1264616, which says that you need to define the bean for the client in the feign configuration like this:
@Bean
public Client feignClient() {
return new Client.Default(null, null);
}
I did that and it is working now, however I've no idea what this default client actually does and if it will break some of the configuration etc... so I'm really not sure if that's a solution or not. I'm also wondering, why the spring configuration spring.cloud.loadbalancer.ribbon.enabled=false
does not do anything at all.
Perhaps I need to wait for an zuul update (which might not happen)?
I'm using spring cloud 2020.0.1 and spring boot 2.4.2