本文鏈接:https://blog.csdn.net/zhongzunfa/article/details/82791903
1、概述
今天一個朋友, 遇到一個如何在使用spring cloud feign 傳遞token 等參數問題。
2、解決方案
2.1 創建類繼承RequestInterceptor
創建類繼承RequestInterceptor 具體如下代碼所示:
2.2 在@configuration 類中定義其
2.3 在yml 或者properties 中添加下面關鍵配置
# To set thread isolation to SEMAPHORE
3、總結
按照上面的操作就可以將上一個服務或者是前端傳遞過來的header參數傳遞到下一個服務中去。
需要注意的是, 每個請求都會攔截設置上header信息。
4. 參考地址
http://cloud.spring.io/spring-cloud-openfeign/single/spring-cloud-openfeign.html