【问题标题】:Intellij Idea taking forever to resolve maven dependenciesIntellij Idea 永远解决 maven 依赖项
【发布时间】:2014-10-31 06:42:13
【问题描述】:

我正在使用 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.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.2.2</version>

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

  <scm>
    <connection>scm:git:git@github.com:FasterXML/jackson-databind.git</connection>
    <developerConnection>scm:git:git@github.com:FasterXML/jackson-databind.git</developerConnection>
    <url>http://github.com/FasterXML/jackson-databind</url>
    <tag>jackson-databind-2.2.2</tag>
  </scm>

  <properties>
    <osgi.export>
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.annotation,
com.fasterxml.jackson.databind.cfg,
com.fasterxml.jackson.databind.deser,
com.fasterxml.jackson.databind.deser.impl,
com.fasterxml.jackson.databind.deser.std,
com.fasterxml.jackson.databind.exc,
com.fasterxml.jackson.databind.ext,
com.fasterxml.jackson.databind.introspect,
com.fasterxml.jackson.databind.jsonschema,
com.fasterxml.jackson.databind.jsonFormatVisitors,
com.fasterxml.jackson.databind.jsontype,
com.fasterxml.jackson.databind.jsontype.impl,
com.fasterxml.jackson.databind.module,
com.fasterxml.jackson.databind.node,
com.fasterxml.jackson.databind.ser,
com.fasterxml.jackson.databind.ser.impl,
com.fasterxml.jackson.databind.ser.std,
com.fasterxml.jackson.databind.type,
com.fasterxml.jackson.databind.util
    </osgi.export>
    <osgi.import>
com.fasterxml.jackson.annotation,
com.fasterxml.jackson.core,
com.fasterxml.jackson.core.base,
com.fasterxml.jackson.core.format,
com.fasterxml.jackson.core.json,
com.fasterxml.jackson.core.io,
com.fasterxml.jackson.core.util,
com.fasterxml.jackson.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/jackson/databind/cfg</packageVersion.dir>
    <packageVersion.package>com.fasterxml.jackson.databind.cfg</packageVersion.package>
  </properties>

  <dependencies>
    <!-- Builds on core streaming API; also needs core annotations -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.2.2</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-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/jackson/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/jackson-annotations/javadoc/2.1.1/</link>
            <link>http://fasterxml.github.com/jackson-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>

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

而且它永远停留在这里。

这是我的 Maven 设置:

我按照this SO answer中给出的步骤操作。

请让我知道我在哪里做错了以及如何摆脱它。

编辑

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

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

【问题讨论】:

  • 您的小屏幕截图中的文件名指示符会改变吗?
  • @specializt 我希望你在谈论第一个屏幕截图。它的进度条一直在左右移动。那里没有任何变化。它卡在 jackson-databind-2.2.2.jar
  • 你在代理后面吗?
  • @EdwinDalorzo nopes.
  • 如果你从命令行运行maven,它工作正常吗?还是它也冻结了?我认为值得知道这是与 IntelliJ 相关的问题还是仅与 maven 相关的问题。

标签: java maven intellij-idea


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

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

    mvn compile -T 8
    

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

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

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

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

    mvn clean install -T 8 -o -DskipTests 
    

    【讨论】:

    • 您使用哪种处理器?
    • 英特尔至强 E3-158L。这是所有远程请求都需要时间而不是处理器。不确定 20 是否是最佳数量。也许 4 更好。
    • 会试试看@Philip!
    【解决方案3】:

    选择文件、设置,然后将用于 Maven 导入的 VM 选项设置为 -Xms1024m -Xmx2048m

    访问https://www.programmersought.com/article/56414660398/

    【讨论】:

      【解决方案4】:

      对我来说,问题与 https://repo.maven.apache.org/maven2 有关,它没有响应。 我在 settings.xml 中添加了另一个镜像(maven-central.storage.googleapis.com)

      【讨论】:

        猜你喜欢
        • 2018-05-07
        • 2021-03-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-28
        • 1970-01-01
        • 1970-01-01
        • 2012-07-12
        相关资源
        最近更新 更多