Creating a client manually

If you are not convinced by the annotation-like style, you may always create a Feign client manually using the Feign Builder API. Feign has several features that can be customized, such as encoders and decoders for messages or HTTP client implementation:

AccountClient accountClient = Feign.builder().client(new OkHttpClient())    .encoder(new JAXBEncoder())    .decoder(new JAXBDecoder())    .contract(new JAXRSContract())    .requestInterceptor(new BasicAuthRequestInterceptor("user", "password"))    .target(AccountClient.class, "http://account-service");

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.