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:
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With