Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ idea can't update any maven repositories

Problem:

I have a maven project that builds & compiles fine using maven tool from command-line.

Then I have IntelliJ IDEA that refuses to build said project, claiming that some of dependencies are not available.

I've found out that the root of the problem is in fact that IntelliJ can't connect to maven repositories which contain said dependencies. Of repositories, there are 3:

  1. apache's maven repo (https://repo.maven.apache.org/maven2)

  2. sonatype's oss repo (https://oss.sonatype.org/content/repositories/snapshots)

  3. company's internal repo (url omitted)

All three are available, accessible through browser for viewing, and dependencies from them are fetched using maven command line interface.

But, IntelliJ just says ".. can't reconnect" and shows errors about updating said repos. I've tried to use different maven options (my local installation, 3.5.2; intellij's bundled maven2 and maven3), to no avail yet.

Any idea why that could happened?

like image 859
Mikhail Krutov Avatar asked Feb 20 '18 13:02

Mikhail Krutov


People also ask

How do I force an update project in IntelliJ?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Build, Execution, Deployment | Build Tools. and select the Auto-Reload Settings option. Reload changes in the build scripts: this option is selected by default.


1 Answers

First, if you work in a big company/corporation, there's a good chance you're using a proxy, be sure to ask your coworkers about configuring your connection. Also, there is probably some Artifactory/Nexus repository in use, which also needs to be configured to allow dependencies to be downloaded. All of this information should be included in the settings.xml file, which should be in the Maven settings (or other build tool, but I only used Maven).

The other thing is that there are problems with the Maven bundled into Intellij. I tried configuring it in many ways inside the IDE, but unfortunately nothing helped, even though the settings.xml file was in the .m2 folder.

I installed a standalone Maven where I put the settings.xml file in the /conf folder. Then just point to the Maven location inside the IDE, preferably delete the contents of the .m2 folder (this will remove both the local settings and the downloaded dependencies) and everything should work fine.

Also remember about VPN connection - sometimes downloading artifacts from repositories is only possible through it.

like image 130
bartoni Avatar answered Oct 03 '22 22:10

bartoni