简体   繁体   English

IntelliJ IDEA 无法更新任何 maven 存储库

[英]IntelliJ idea can't update any maven repositories

Problem:问题:

I have a maven project that builds & compiles fine using maven tool from command-line.我有一个 maven 项目,它使用命令行中的 maven 工具构建和编译良好。

Then I have IntelliJ IDEA that refuses to build said project, claiming that some of dependencies are not available.然后我有 IntelliJ IDEA 拒绝构建所述项目,声称某些依赖项不可用。

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.我发现问题的根源实际上是 IntelliJ 无法连接到包含所述依赖项的 maven 存储库。 Of repositories, there are 3:在存储库中,有 3 个:

  1. apache's maven repo ( https://repo.maven.apache.org/maven2 ) apache 的 maven 回购协议( https://repo.maven.apache.org/maven2

  2. sonatype's oss repo ( https://oss.sonatype.org/content/repositories/snapshots ) sonatype 的 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.这三个都可用,可以通过浏览器访问以供查看,并且可以使用 maven 命令行界面获取它们的依赖项。

But, IntelliJ just says ".. can't reconnect" and shows errors about updating said repos.但是,IntelliJ 只是说“.. 无法重新连接”并显示有关更新所述回购协议的错误。 I've tried to use different maven options (my local installation, 3.5.2; intellij's bundled maven2 and maven3), to no avail yet.我尝试使用不同的 maven 选项(我的本地安装,3.5.2;intellij 的捆绑 maven2 和 maven3),但无济于事。

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.此外,可能有一些 Artifactory/Nexus 存储库正在使用中,也需要对其进行配置以允许下载依赖项。 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).所有这些信息都应该包含在settings.xml文件中,该文件应该在 Maven 设置(或其他构建工具,但我只使用 Maven)中。

The other thing is that there are problems with the Maven bundled into Intellij.另一件事是捆绑到 Intellij 中的 Maven 存在问题。 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.我尝试在 IDE 中以多种方式配置它,但不幸的是没有任何帮助,即使settings.xml文件位于.m2文件夹中。

I installed a standalone Maven where I put the settings.xml file in the /conf folder.我安装了一个独立的 Maven,我将settings.xml文件放在/conf文件夹中。 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.然后只需指向 IDE 中的 Maven 位置,最好删除.m2文件夹的内容(这将删除本地设置和下载的依赖项),一切正常。

Also remember about VPN connection - sometimes downloading artifacts from repositories is only possible through it.还要记住 VPN 连接 - 有时只能通过它从存储库下载工件。

Are you using net though proxy in your company? 您在公司中使用网络代理吗? btw, you can try by delete the .m2/repository directory and re sync again. 顺便说一句,您可以尝试删除.m2 / repository目录,然后再次重新同步。

I have run into this many times also and the only solution that has worked is to restart IntelliJ which has worked every time.我也遇到过很多次,唯一有效的解决方案是重新启动每次都有效的 IntelliJ。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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