@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");
}
}
下面一种权重要高于上面一种