【发布时间】:2017-05-19 03:04:05
【问题描述】:
我有这个 Gradle 依赖项的 Spring Boot 应用程序:
compile("org.springframework.cloud:spring-cloud-starter-eureka")
compile("org.springframework.cloud:spring-cloud-starter-feign")
compile("org.springframework.cloud:spring-cloud-starter-ribbon")
compile("org.springframework.cloud:spring-cloud-starter-hystrix")
compile("org.springframework.cloud:spring-cloud-starter-config")
我还有 Feign 客户端:
@FeignClient(name = "client")
public interface FeignService {
@RequestMapping(value = "/path", method = GET)
String response();
}
我的application.properties:
client.ribbon.listOfServers = http://localhost:8081
ribbon.eureka.enabled=false
当查询时间超过 1 秒时出现异常:
com.netflix.hystrix.exception.HystrixRuntimeException: response timed-out and no fallback available.
所以我的问题是:如何设置自定义 Feign 客户端连接超时?例如 2 秒。
【问题讨论】: