java Intellij Idea 需要永远解决 maven 依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25700652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 08:29:31  来源:igfitidea点击:

Intellij Idea taking forever to resolve maven dependencies

javamavenintellij-idea

提问by rahulserver

I am using intellij idea ultimate version 12.1.4 and trying to use maven with a project. Here is my pom.xml:

我正在使用 intellij idea 终极版 12.1.4 并尝试在项目中使用 maven。这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.fasterxml</groupId>
    <artifactId>oss-parent</artifactId>
    <version>10</version>
  </parent>

  <groupId>com.fasterxml.Hymanson.core</groupId>
  <artifactId>Hymanson-databind</artifactId>
  <version>2.2.2</version>

  <name>Hymanson-databind</name>
  <description>General data-binding functionality for Hymanson: works on core streaming API</description>
  <url>http://wiki.fasterxml.com/HymansonHome</url>

  <scm>
    <connection>scm:git:[email protected]:FasterXML/Hymanson-databind.git</connection>
    <developerConnection>scm:git:[email protected]:FasterXML/Hymanson-databind.git</developerConnection>
    <url>http://github.com/FasterXML/Hymanson-databind</url>
    <tag>Hymanson-databind-2.2.2</tag>
  </scm>

  <properties>
    <osgi.export>
com.fasterxml.Hymanson.databind,
com.fasterxml.Hymanson.databind.annotation,
com.fasterxml.Hymanson.databind.cfg,
com.fasterxml.Hymanson.databind.deser,
com.fasterxml.Hymanson.databind.deser.impl,
com.fasterxml.Hymanson.databind.deser.std,
com.fasterxml.Hymanson.databind.exc,
com.fasterxml.Hymanson.databind.ext,
com.fasterxml.Hymanson.databind.introspect,
com.fasterxml.Hymanson.databind.jsonschema,
com.fasterxml.Hymanson.databind.jsonFormatVisitors,
com.fasterxml.Hymanson.databind.jsontype,
com.fasterxml.Hymanson.databind.jsontype.impl,
com.fasterxml.Hymanson.databind.module,
com.fasterxml.Hymanson.databind.node,
com.fasterxml.Hymanson.databind.ser,
com.fasterxml.Hymanson.databind.ser.impl,
com.fasterxml.Hymanson.databind.ser.std,
com.fasterxml.Hymanson.databind.type,
com.fasterxml.Hymanson.databind.util
    </osgi.export>
    <osgi.import>
com.fasterxml.Hymanson.annotation,
com.fasterxml.Hymanson.core,
com.fasterxml.Hymanson.core.base,
com.fasterxml.Hymanson.core.format,
com.fasterxml.Hymanson.core.json,
com.fasterxml.Hymanson.core.io,
com.fasterxml.Hymanson.core.util,
com.fasterxml.Hymanson.core.type,
org.xml.sax,org.w3c.dom, org.w3c.dom.bootstrap, org.w3c.dom.ls,
javax.xml.datatype, javax.xml.namespace, javax.xml.parsers
</osgi.import>

    <!-- Generate PackageVersion.java into this directory. -->
    <packageVersion.dir>com/fasterxml/Hymanson/databind/cfg</packageVersion.dir>
    <packageVersion.package>com.fasterxml.Hymanson.databind.cfg</packageVersion.package>
  </properties>

  <dependencies>
    <!-- Builds on core streaming API; also needs core annotations -->
    <dependency>
      <groupId>com.fasterxml.Hymanson.core</groupId>
      <artifactId>Hymanson-annotations</artifactId>
      <version>2.2.2</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.Hymanson.core</groupId>
      <artifactId>Hymanson-core</artifactId>
      <version>2.2.2</version>
    </dependency>

    <!-- and for testing, JUnit is needed, as well as quite a few
         libs for which we use reflection for code, but direct dep for testing
      -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>2.2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>1.7.9</version>
      <scope>test</scope>
    </dependency>
    <dependency> <!--  from core we just test for repackaged cglib, not hibernate proper -->
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-cglib-repack</artifactId>
      <version>2.1_3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
          <excludes>
            <exclude>com/fasterxml/Hymanson/failing/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${javadoc.version}</version>
        <configuration>
          <links>
            <link>http://docs.oracle.com/javase/6/docs/api/</link>
            <link>http://fasterxml.github.com/Hymanson-annotations/javadoc/2.1.1/</link>
            <link>http://fasterxml.github.com/Hymanson-core/javadoc/2.1.1/</link>
          </links>
        </configuration>
      </plugin>
      <plugin>
        <!-- Inherited from oss-base. Generate PackageVersion.java.-->
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <executions>
          <execution>
            <id>process-packageVersion</id>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <properties>
        <maven.test.skip>true</maven.test.skip>
        <skipTests>true</skipTests>
      </properties>
    </profile>
  </profiles>

</project>

When I do a maven dependency resolution, its taking forever to get it through and this is what I get:

当我进行 maven 依赖解析时,它需要很长时间才能通过,这就是我得到的:

enter image description here

在此处输入图片说明

And it sticks here forever.

它永远粘在这里。

Here are my maven settings:

这是我的 Maven 设置:

enter image description here

在此处输入图片说明

I followed steps given in thisSO answer.

我遵循了这个SO 答案中给出的步骤。

Please let me know where am I doing wrong and how do I get rid of it.

请让我知道我做错了什么以及如何摆脱它。

EDIT

编辑

If this should help, I am trying to run this code: https://github.com/hmkcode/Android/tree/master/java-post-gcm

如果这有帮助,我正在尝试运行此代码:https: //github.com/hmkcode/Android/tree/master/java-post-gcm

I am not sure whether its an issue with the pom.xml itself. Perhaps if someone is able to have it working on his IDE, it may be concluded that its an issue with my specific IDE config.

我不确定它是否是 pom.xml 本身的问题。也许如果有人能够在他的 IDE 上使用它,那么可能会得出结论,这是我的特定 IDE 配置的问题。

回答by rhozet

If this is an issue very specific to intellij, I would suggest do the following steps You can try running mvn clean install.(Depending on your network speed it will pull every dependency)

如果这是一个非常特定于 intellij 的问题,我建议执行以下步骤您可以尝试运行 mvn clean install。(根据您的网络速度,它将拉取每个依赖项)

Change intellij settings in Preferences->build,execution,deployment->maven->Maven home directory->{now change this to point to your mvn home rather than bundled mvn}

在 Preferences->build,execution,deployment->maven->Maven home directory->{now 将其更改为指向您的 mvn home 而不是捆绑的 mvn} 中的更改 Intellij 设置

mvn -v in command line should give you the maven home path. Now it won't try to download dependencies again.

命令行中的 mvn -v 应该为您提供 maven 主路径。现在它不会再次尝试下载依赖项。

回答by Philip Rego

File | Settings | Build, Execution, Deployment | Build Tools | Maven | Threads (-T option) | 16 (or however many threads you want to try)

档案 | 设置 | 构建、执行、部署 | 构建工具 | 马文 | 线程(-T 选项)| 16 个(或者你想尝试多少个线程)

mvn compile -T 8

I had the same issue. Maven was taking an hour in IntelliJ and also running from the command line. Using the -T parameter you can tell Maven to use more threads to download artifacts simultaneously. Takes only about 15 minutes now.

我遇到过同样的问题。Maven 在 IntelliJ 中花费了一个小时,并且还从命令行运行。使用 -T 参数可以告诉 Maven 使用更多线程同时下载工件。现在只需要大约 15 分钟。

Don't use bundled mvn. Point "Maven home directory" to the path on your file system.

不要使用捆绑的 mvn。将“Maven 主目录”指向文件系统上的路径。

After you're done building. Check "Work offline". This stops mvn from searching remote websites each time you build. Uncheck when you update your POM file so it can search for the changes.

搭建完成后。选中“离线工作”。这会阻止 mvn 在您每次构建时搜索远程网站。在更新 POM 文件时取消选中,以便它可以搜索更改。

You can also skip tests. This is evertyhing from the command line.

您也可以跳过测试。这是来自命令行的一切。

mvn clean install -T 50 -o -DskipTests