SpringBoot 3 RestTemplate-HttpComponentsClientHttpRequestFactory incompatible with org.apache.http.client.HttpClient

81 Views Asked by At
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient());

'HttpComponentsClientHttpRequestFactory(org.apache.hc.client5.http.classic.HttpClient)' in 'org.springframework.http.client.HttpComponentsClientHttpRequestFactory' cannot be applied to '(org.apache.http.client.HttpClient)'

Need solution to solve this in any other alternative way with this dependency specifically.

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.2</version>
</dependency>
1

There are 1 best solutions below

0
softwareguy On

As mentioned in the Migration Guide, support for Apache HttpClient has been removed in Spring Framework 6.0, immediately replaced by org.apache.httpcomponents.client5:httpclient5. It is not possible to use apache httpclient 4.x versions along with spring 6.x version.