Update springboot 2.7.8 to 3.2.1 - restTemplate not working in spring 3x

288 Views Asked by At

org.apache.httpcomponents.client5:httpclient5:5.2.1.

I have updated httpcomponent maven dependency to httpclient5.

when i tried to hit my restTemplate api it is throwing error as mentioned below.

public ResponseEntity<String> sendPostRequest(RestTemplate restTemplate, String url, Object requestBody, HttpHeaders headers) {`
    HttpEntity<Object> request = new HttpEntity<>(requestBody, header);
    return restTemplate.exchange(url, HttpMethod.POST, request, String.class);
}
[nio-8801-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/digital-provider] threw exception [Handler dispatch failed: java.lang.NoSuchMethodError: 'org.apache.hc.core5.http.ClassicHttpResponse org.apache.hc.client5.http.classic.HttpClient.executeOpen(org.apache.hc.core5.http.HttpHost, org.apache.hc.core5.http.ClassicHttpRequest, org.apache.hc.core5.http.protocol.HttpContext)'].

I tried updating the httpcomponent version and etc but nothing works.

Thanks in advance can anyone let mw know what is the mistake im making im not sure i have updated the things but the existing code itself breaking.

0

There are 0 best solutions below