I had to upgrade the Spring Boot dependency 2.7.5 --> 3.0.2:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath />
</parent>
The pom.xml
currently references a relatively new version of HttpClient
, 4.5.3:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
The code uses the org.apache.http
classes which now produce the following error on Maven Build:
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
--> incompatible types: org.apache.http.impl.client.CloseableHttpClient cannot be converted to org.apache.hc.client5.http.classic.HttpClient
To tackle this error, I replaced all occurrences of org.apache.http
with org.apache.hc.httpclient5
per https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/migration-to-classic.html :
import org.apache.hc.httpclient5.conn.ssl.SSLConnectionSocketFactory;
import org.apache.hc.httpclient5.conn.ssl.TrustSelfSignedStrategy;
import org.apache.hc.httpclient5.impl.client.CloseableHttpClient;
import org.apache.hc.httpclient5.impl.client.HttpClients;
import org.apache.hc.httpclient5.ssl.SSLContextBuilder;
But now the error is
package org.apache.hc.httpclient5.conn.ssl does not exist . It can't resolve the HC5 package. Any tips?
NOTE: I also tried replacing the HttpClient dependency with the new httpclient5 dependency, but it's the same error:
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>