Search code examples
javamavenintellij-ideaclasspathapache-commons-httpclient

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


Solution

  • 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 :)