1

I am using Maven. when I include

<dependency> 
<groupId>org.apache.httpcomponents.client5</groupId> <artifactId>httpclient5</artifactId> 
<version>5.2.1</version>
</dependency>

in pom.xml i got httpclient5-5.2.1.jar, httpcore5-5.2.jar, and httpcore5-h2-5.2.jar in library folder of project.

I am noticing issues with HTTP client behavior since I have been upgrading the httpclient from 4 to 5 and it could be that RestTemplate is falling back to the JDK client.

org.apache.hc.client5.http.classic.HttpClient client = org.apache.hc.client5.http.impl.classic.HttpClients.custom()
                    .setConnectionManager(connectionManager)
                    .build(); 
final org.springframework.http.client.HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(client);

the above setter method is causing the below compile time issue

The type org.apache.http.client.HttpClient cannot be resolved. It is indirectly referenced from required .class files

Ajay Takur
  • 6,079
  • 5
  • 39
  • 55
  • Are you using a dependency management tool such as Apache Maven or Apache Gradle? Those tools will automatically download transitive dependencies, that is, libraries needed by the libraries that you need. See [*What is a transitive Maven dependency?*](https://stackoverflow.com/q/41725810/642706) – Basil Bourque May 25 '23 at 19:43
  • Yep i am using maven. when i include org.apache.httpcomponents.client5 httpclient5 5.2.1 in pom.xml i got httpclient5-5.2.1.jar, httpcore5-5.2.jar, and httpcore5-h2-5.2.jar – Ajay Takur May 25 '23 at 19:46
  • Those facts should appear in your Question. – Basil Bourque May 25 '23 at 19:47
  • Pls check it now. – Ajay Takur May 25 '23 at 19:56

0 Answers0