Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why IntelliJ IDEA doesn't see HttpClients?

I've added following into dependencies section of my pom.xml:

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.4.1</version>
        <scope>test</scope>
    </dependency>

But when I add the 1st line of "Quick start guide" (http://hc.apache.org/httpcomponents-client-4.4.x/quickstart.html):

CloseableHttpClient httpclient = HttpClients.createDefault();

IntelliJ IDEA highlights "HttpClients" and tells me:

Cannot resolve symbol 'HttpClients'

It looks like I have mistake with configuration. What exactly is wrong? please advise how to add support for HttpClients into the project?

Thanks!

P.S. Learned a bit more, looks like "" is redundant and wrong for this case, I removed it but that didn't help: still non-compilable.

EDIT: If I put cursor to 'HttpClients' and hit "Alt-enter" the pop-up doesn't contain any class to import. See screenshot: enter image description here

like image 729
Budda Avatar asked Apr 20 '15 02:04

Budda


2 Answers

Download the jar file from https://jar-download.com/artifacts/org.apache.httpcomponents/httpclient/4.5.6/source-code

Extract the .jar file name httpclient-4.5.6.jar. Form a directry name lib under your project and import this .jar file to it. Right click your .jar file and click addtolibrary.

like image 162
H Soora Avatar answered Oct 03 '22 07:10

H Soora


It looks like my IntelliJ had issues with caching, cleaning cache with following re-importing of the project helped.

I found tips on that here: IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

P.S. Though few other project were broken as a result of this action. Looks like I need to keep learning :)

like image 35
Budda Avatar answered Oct 03 '22 06:10

Budda