有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Maven:Apache Spark在尝试“mvn包”时出错

我已经在本地安装了spark 1.3.1,方法是下载zip并将其解压缩到我的主存储库中,这样我就可以在home/my user name/spark-1.3.1中找到它
接下来,我想使用Java进行工作,为了让它工作,我通过以下命令安装了maven:

$ sudo apt-get install maven

然后我用这个命令检查了版本:

mvn -version

这给了我:

Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"

接下来,我想从当前的托存文档中使用Maven创建一个java项目/:

mvn archetype:generate -DgroupId=projet -DartifactId=Indexing -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

这意味着我的pom。xml文件位于存储库文档/projet/index中/ 以下是我在pom中得到的信息。xml:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mif37.projet</groupId>
  <artifactId>Indexing</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>IndexingMapReduce</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

在那之后,我在标记依赖项中加入了一个要spark的依赖项,所以我创建了这个pom。xml:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mif37.projet</groupId>
  <artifactId>Indexing</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>IndexingMapReduce</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.10</artifactId>
      <version>1.3.1</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

然后我从pom所在的存储库运行命令行。xml:

mvn package

但最后我得到的是:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9:18.021s
[INFO] Finished at: Sun May 31 20:49:52 CEST 2015
[INFO] Final Memory: 12M/137M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Indexing: Could not resolve dependencies for project projet:Indexing:jar:1.0-SNAPSHOT: Could not transfer artifact org.apache.spark:spark-core_2.10:jar:1.3.1 from/to central (http://repo.maven.apache.org/maven2): GET request of: org/apache/spark/spark-core_2.10/1.3.1/spark-core_2.10-1.3.1.jar from central failed: Connection reset -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

任何人都可以指出我做错了什么?? 谢谢


共 (1) 个答案

  1. # 1 楼答案

    你的pom。xml和流程很好。存在防火墙/连接性问题——如下所述:

    .spark:spark-core_2.10:jar:1.3.1 from/to central (http://repo.maven.apache.org/maven2): GET request of: org/apache/spark/spark-core_2.10/1.3.1/spark-core_2.10-1.3.1.jar from central failed: Connection reset -> [Help 1]
    [ERROR] 
    

    你可以在一个“开放”的环境中重复你的步骤,比如在家里而不是在工作中,自己验证