我有一个Spring Boot应用程序,想要创建一个Feign客户端,该客户端具有静态定义的标头值(用于auth,但不用于基本auth)。我找到了@Headers
注释,但它似乎在Spring Boot领域中不起作用。我怀疑这与使用SpringMvcContract
。
这是我要工作的代码:
@FeignClient(name = "foo", url = "http://localhost:4444/feign")
@Headers({"myHeader:value"})
public interface LocalhostClient {
Run Code Online (Sandbox Code Playgroud)
但是它不添加标题。
我用自己的尝试制作了一个干净的Spring Boot应用程序,并将其发布到github上:github示例
我能够使其起作用的唯一方法是将其定义RequestInterceptor
为全局bean,但是我不想这样做,因为它会影响其他客户端。