spark源码学习(2)--编译源码+踩坑记录

2019-12-06  本文已影响0人  小北觅

写个博客记录一下自己编译spark源码和运行spark源码中examples例子的过程。我跑的程序是JavaSparkPi这个例子,求π的值。结果如下:

下面是整个实验过程:

1.首先用git把源码clone下来,我用的是2.4.4版本,在windows7环境下编译。

2.直接用官方文档中的方法,在git中进入spark源码目录,执行下面的命令。

./build/mvn -DskipTests clean package

3.编译源码花了40多分钟吧,没有出错。

4.用IDEA导入编译后的源码。

5.准备运行spark-examples下面的例子。直接run,发现会出现各种类找不到,未定义什么的。此时按如下方法做。

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>compile</scope>
    </dependency>
<dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlet</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-security</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-http</artifactId>
      <scope>compile</scope>
    </dependency>

接下来就可以直接run了。

上一篇 下一篇

猜你喜欢

热点阅读