srpingcloud 服务调用Feign方式常见错误解决

报错信息:
1)
Consider revisiting the conditions above or defining a bean of type 'org.springframework.cloud.netflix.feign.FeignContext' in your configuration.
解决方法:
参考链接:https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html

在@Configuration类中添加一下代码:
 
@Bean
public Feign.Builder feignBuilder() {
return Feign.builder();
}
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
添加依赖:

io.github.openfeign
feign-core
RELEASE



2)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.honghu.cloud.modules.remote.HelloRemote': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: feign/slf4j/Slf4jLogger
解决方法:添加依赖jar包


com.netflix.feign
feign-slf4j
8.14.4


3)
Load balancer does not have available server for client
参考链接:https://stackoverflow.com/questions/41401009/load-balancer-does-not-have-available-server-for-client
解决方法:
eureka.client.fetchRegistry=true

4)
feign.RetryableException: Read timed out executing
参考链接:https://blog.csdn.net/luwei42768/article/details/79529224
解决方法:
ribbon:
ReadTimeout: 60000
ConnectTimeout: 60000


解决Feign第一次请求timeout问题
#索性禁用Feign的Hystrix
feign.hystrix.enabled=false

你可能感兴趣的:(spring,cloud)