gpt4 book ai didi

java - 迁移 Feign Load Balancer 实现以兼容 Spring cloud 2020.0.0

转载 作者:行者123 更新时间:2023-12-05 06:06:05 24 4
gpt4 key购买 nike

我在下面实现了 Feign 负载均衡器,它与 spring cloud 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 cloud 版本升级到 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>

关于java - 迁移 Feign Load Balancer 实现以兼容 Spring cloud 2020.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65884281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com