繁体   English   中英

迁移 Feign 负载均衡器实现以兼容 Spring 云 2020.0.0

[英]Migrate Feign Load Balancer implementation to compatible with Spring cloud 2020.0.0

我有以下 Feign 负载均衡器的实现,它与 spring 云Hoxtan SR6依赖项一起使用。

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);
}
}

我尝试将 spring 云版本升级到2020.0.0 我注意到以下软件包不再可用。

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

如何更改当前的实现? 或者什么依赖会提供这些包?

我遇到了同样的问题。 最后,我通过添加波纹管依赖来解决错误。

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-openfeign-core</artifactId>
    <version>2.2.6.RELEASE</version>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM