I am defining a bean of type CloseableHttpClient in my Spring boot app. But still I get the error that the bean could not be found.
@Bean
@Primary
public RestTemplate restTemplate(RestTemplateBuilder builder, @Qualifier("pooledClient") CloseableHttpClient httpClient) {
return builder.requestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)).build();
}
@Bean
public CloseableHttpClient httpClient() {
return HttpClientBuilder.create().build();
}
Parameter 1 of method restTemplate in com.MyConfiguration required a bean of type 'org.apache.http.impl.client.CloseableHttpClient' that could not be found.
Action:
Consider defining a bean of type 'org.apache.http.impl.client.CloseableHttpClient' in your configuration.