3

I have below implementation of Feign Load balancer which is working with spring cloud Hoxtan SR6 dependencies.

import feign.auth.BasicAuthRequestInterceptor;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory;
import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;
import org.springframework.context.annotation.Bean;

public class ClientConfig {

@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor(
        @Value("${username}") String username,
        @Value("${password}") String password) {
    return new BasicAuthRequestInterceptor(username, password);
}

@Autowired
private CachingSpringLoadBalancerFactory cachingFactory;
@Autowired
private SpringClientFactory clientFactory;

@Value("${keystore.location}")
private String keyStoreLocation;
@Value("${keystore.secPhase}")
private String keyPassword;

@Bean
public Client feignClient() {
    SslUtils.KeystoreConfig truststoreConfig = SslUtils.KeystoreConfig.builder().type("JKS").location(keyStoreLocation).password(keyPassword).build();
    SocketFactory factory = new SocketFactory(() -> SslUtils.newContext(null, truststoreConfig));
    NoopHostnameVerifier verifier = new NoopHostnameVerifier();
    Client.Default client = new Client.Default(factory, verifier);
    return new LoadBalancerFeignClient(client, cachingFactory, clientFactory);
}
}

I tried to upgrade spring cloud version to 2020.0.0. I noticed below packages no longer available.

import org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory;
import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;

How can I change the current implementation? or what dependency will provide these packages?

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115

1 Answers1

1

I was experiencing the same issue. Finally, I solve the error by adding the bellow dependency.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-openfeign-core</artifactId>
    <version>2.2.6.RELEASE</version>
</dependency>
Mark Wu
  • 41
  • 3
  • 1
    no, this is not a good idea, you are mixing versions and this could have consequences. – red Apr 02 '22 at 04:17