Feign设置Header头部参数

@FeignClient(name = "kafka-client", url = "http://kafka.xxx.com")
public interface KafkaClient {

    @GetMapping(value = "/api/clusterManager/listTopics")
    @Headers( {"cache-control: no-cache", "username: wangyong@xxx.com"})
    TopicsResponse listTopics(@RequestParam("clusterName") String clusterName,
                              @RequestParam("clusterArea") String clusterArea);
}

 第二中全局

 

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;


@Configuration
@Component
public class FeignInterceptor implements RequestInterceptor {

    public void apply(RequestTemplate requestTemplate){
        requestTemplate.header("XX_TOKEN", "aaa");
    }
}

下面一种权重要高于上面一种

上一篇:Hive HMS Canary 时间较长异常分析


下一篇:Required String parameter 'xxxx' is not present