Spring Cloud Alibaba OpenFeign 超时时间

package com.wsm.order.config;

import feign.Contract;
import feign.Logger;
import feign.Request;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 全局配置: 当使用@Configuration会将配置作用所有的报务提供方
 * 局部配置: 1 通过配置类:如果只针对个别服务进行配置,就不要加@Configuration
 *            2 通过配置文件
 */
//@Configuration
public class FeignConfig {

    @Bean
    public Logger.Level feignLoggerLevel(){
        return Logger.Level.FULL;
    }

//    /**
//     * 修改契约配置,支持Feign原生的注解
//     * @return
//     */
//    @Bean
//    public Contract feignContract(){
//        return new Contract.Default();
//    }

//    /**
//     * 超时时间配置
//     * @return
//     */
//    @Bean
//    public Request.Options options() {
//        return new Request.Options(5000, 10000);
//    }

}
server:
  port: 8040
  #应用名称  (nacos 会将该名称当作服务名称)
spring:
  application:
    name: order-openfeign-service
  cloud:
    nacos:
#      server-addr: 127.0.0.1:8848
      server-addr: 192.168.133.128:8847  #集群 nginx 负载均衡访问 nacos
      discovery:
        username: nacos
        password: nacos
        namespace: public
#springboot 默认的日志级别是info,feign的debug日志级别就不会输出
logging:
  level:
#    com.wsm.order.feign: debug
    com.wsm.order.feign.StockFeignService: debug
# Feign 日志局部配置
feign:
  client:
    config:
      product-service:
        loggerLevel: BASIC
        contract: feign.Contract.Default #设置为默认的契约 (还原成原生注解)
        connectTimeout: 5000 #连接超时时间,默认2s
        readTimeout: 10000 #请求处理超时时间,默认5s
原文地址:https://www.cnblogs.com/mingforyou/p/15526312.html