Я использую версию SpringBoot 3.4.1 и обнаружил, что она по умолчанию поддерживает httpclient5
Я пытаюсь настроить свой RestTemplate.
Ниже приведен класс, который я настраиваю:
Код: Выделить всё
@Configuration
public class BlockingRestTemplateCustomizer {
@Bean("restTemplate")
public RestTemplate restTemplate() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(100);
connectionManager.setDefaultMaxPerRoute(20);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(3000)
.build();
HttpClient httpClient = HttpClients.custom()
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(requestConfig)
.build();
ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); // Line A CTE Error
return new RestTemplate(factory);
}
}
Error I am facing error @ Line A compile time Error , it says that httpclient --> parameter should be of httpclient5 type
Я обновил свой pom, добавив зависимость ниже:
Код: Выделить всё
org.springframework.boot
spring-boot-starter-web
org.apache.httpcomponents
httpclient5
org.apache.httpcomponents
httpclient
4.5.13
org.apache.httpcomponents
httpcore
4.4.14
Код: Выделить всё
@SpringBootApplication
@EnableAutoConfiguration(exclude = {
RestTemplateAutoConfiguration.class,
HttpClientAutoConfiguration.class
})// Exclude RestTemplate auto-configuration
public class MsscBreweryClientApplication {
public static void main(String[] args) {
SpringApplication.run(MsscBreweryClientApplication.class, args);
}
}
But Still error is prevailing , is there a way to httpclient4 inclusion in springBoot 3.x.x version .
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/793 ... ttpclient4
Мобильная версия