Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
476 views
in Technique[技术] by (71.8m points)

java - Migrate Feign Load Balancer implementation to compatible with Spring cloud 2020.0.0

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?

question from:https://stackoverflow.com/questions/65884281/migrate-feign-load-balancer-implementation-to-compatible-with-spring-cloud-2020

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...