0

Feign Request Interceptor に Bean を注入する必要がありますが、取得しています

インスタンス化に失敗しました デフォルトのコンストラクターが見つかりません

public class CustomInterceptor implements RequestInterceptor {

    private final SomeService service;

    public CustomInterceptor(SomeService service) {
        this.service= service;
    }

    @Override
    public void apply(RequestTemplate template) {//service.retrieveSomeInfo to include in headers}
}

@Componentデフォルトのインターセプターになるため、注釈を追加できません。このインターセプターは、一部のクライアント (application.yml) にのみ必要です。

feign:
  client:
    config:
      some-feign-api:
        requestInterceptors:
          - example.feign.CustomInterceptor

@Componentアノテーションなしでこの Feign Request Interceptor に Spring Bean を注入するにはどうすればよいですか?

springboot 2.4.1 と springCloudVersion 2020.0.0 を使用しています

4

0 に答える 0