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:
apache's maven repo (https://repo.maven.apache.org/maven2)
sonatype's oss repo (https://oss.sonatype.org/content/repositories/snapshots)
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?
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.
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.
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