简体   繁体   中英

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!

PS 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:在此处输入图片说明

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM