Tag Archives: Compilation failure

Compilation failure cannot find the class file for org.apache.http.annotation.notthreadsafe

The class file for org.apache.http.annotation.notthreadsafe could not be found


 

Problem phenomenon

Recently, when calling the get request function containing the request body, httpclient-4.5.2.jar and httpcore-4.4.5.jar were referenced.

The following errors are reported during project compilation:

 

Cause analysis

The versions of HttpCore and httpclient do not match

 

Solution

Change the version of HttpCore from 4.4.5 to 4.4.4. Maven refers to the following:

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