简体   繁体   中英

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?

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.

Are you using net though proxy in your company? btw, you can try by delete the .m2/repository directory and re sync again.

I have run into this many times also and the only solution that has worked is to restart IntelliJ which has worked every time.

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