如何解决与Maven中央存储库的连接超时?

时间:2019-03-01 19:41:02

标签: java maven apache-spark

我的pom.xml(只是一个片段)如下:

            <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.10</artifactId>
            <version>2.0.0</version>
        </dependency>

    <dependency>
    <groupId>org.apache.spark</groupId>
    <artifactId>spark-graphx_2.12</artifactId>
    <version>2.4.0</version>
</dependency>

          <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-graphx_2.11</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-sql_2.11</artifactId>
        <version>2.0.0</version>
    </dependency>
      <dependency>
        <groupId>graphframes</groupId>
        <artifactId>graphframes</artifactId>
        <version>0.6.0-spark2.3-s_2.11</version>
    </dependency>
</dependencies>

<repositories>
    <!-- list of other repositories -->
    <repository>
        <id>SparkPackagesRepo</id>
        <url>http://dl.bintray.com/spark-packages/maven</url>
    </repository>
    <repository>              
          <id>central</id>
          <name>Central</name>
          <url>http://repo1.maven.org/maven2</url>
</repository>
 </repositories>

运行以下命令:mvn install生成以下异常:

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.124.215] failed: Connection timed out (Connection timed out) -> [Help 1]

似乎我无法连接到Maven中央存储库或连接问题。 Ani idea plz我的错误在哪里?

如果您注意到连接,请尝试通过端口443连接到repo.maven.apache.org。因此,如果我尝试: telnet repo.maven.apache.org 443我得到了:

    Trying 151.101.124.215...
telnet: connect to address 151.101.124.215: Connection timed out

但是 如果我尝试telnet repo.maven.apache.org 80命令显示:

Trying 151.101.124.215...
Connected to repo.maven.apache.org.
Escape character is '^]'.

settings.xml如下:

<settings>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>securecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>securecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

2 个答案:

答案 0 :(得分:3)

错误很可能是由于您的网络连接,也可能是由于防火墙。这不是Maven或编程问题。

答案 1 :(得分:0)

也许您可以尝试其他镜像站点guide mirror settings