feign客户端和get的param

1cklez4t  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(340)

这是我的配置类:

@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "partner.broker.agreements.rest-client")
public class BrokerAgreementsRestConfig extends RestClientConfig {
    private String investApiKey;
}

我需要通过假客户端发送get请求。我的请求必须有一个带有密钥的标头:

@FeignClient(name = "brokerAgreements", url = "${partner.broker.agreements.rest-client.baseUrl}")
public interface BrokerAgreementsRestClient {

    String X_APP_HEADER = "x-app-name=bundle";
    String X_API_KEY = "x-api-key=%s";
    String X_INVEST_API = String.format(X_API_KEY, new BrokerAgreementsRestConfig().getInvestApiKey());

    @GetMapping(path = "broker-account/siebel/{siebelId}",
            consumes = APPLICATION_FORM_URLENCODED_VALUE,
            headers = {X_APP_HEADER, X_INVEST_API})
    BrokerAccountsRs getBrokerAccounts(@PathVariable(value = "siebelId") String siebelId, @RequestBody String requestBody);
}

但是我的ide说头是不正确的,我的 X_INVEST_API 应该是常量。如我所知,在一个接口中初始化的所有对象都是final。怎么了?为什么需要一个常数?

7fhtutme

7fhtutme1#

我认为你必须使用一个动态值的标题,比如这个问题:

相关问题