本文链接:https://blog.csdn.net/zhongzunfa/article/details/82791903
1、概述
今天一个朋友, 遇到一个如何在使用spring cloud feign 传递token 等参数问题。
2、解决方案
2.1 创建类继承RequestInterceptor
创建类继承RequestInterceptor 具体如下代码所示:
![](https://img-blog.csdnimg.cn/img_convert/27c112e485535e72a530c295032ea9d7.png)
2.2 在@configuration 类中定义其
![](https://img-blog.csdnimg.cn/img_convert/0b62f740bdb6f83876cfa991acab52db.png)
2.3 在yml 或者properties 中添加下面关键配置
# To set thread isolation to SEMAPHORE
![](https://img-blog.csdnimg.cn/img_convert/ebc83ba5e7ff414d9324e8f79256bcad.png)
3、总结
按照上面的操作就可以将上一个服务或者是前端传递过来的header参数传递到下一个服务中去。
需要注意的是, 每个请求都会拦截设置上header信息。
4. 参考地址
http://cloud.spring.io/spring-cloud-openfeign/single/spring-cloud-openfeign.html