Spark-IDEA源码阅读环境搭建(Windows)

一、源码下载和IDE安装

下载Spark源码和 Intellij IDEA并安装

二、jdk和scala安装

1. jdk

下载jdk并安装完成后,环境变量配置省略,可以参考
http://blog.csdn.net/hylisncsb/article/details/47722399

2. scala

windows下,直接下载scala的安装包安装即可

三、Maven安装

直接下载Maven的压缩包,解压即可。

1. Maven 环境变量
1) 新建环境变量  M2_HOME  ,输入值为 Maven 的安装目录;
2) 将 M2 环境变量加入  Path  的最后,%M2_HOME%\bin
3) 测试:mvn-v
2. Maven 仓库配置

由于GFW的原因,Maven的使用会遇到一些问题,现在使用开源中国提供的Maven仓库。 参见:http://maven.oschina.net/content/groups/public/
1) mirrors修改

<mirrors>
    <mirror>
        <id>nexus-osc</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus osc</name>        <url>http://maven.oschina.net/content/groups/public/</url>
    </mirror>
    <mirror>
        <id>nexus-osc-thirdparty</id>
        <mirrorOf>thirdparty</mirrorOf>
        <name>Nexus osc thirdparty</name>        <url>http://maven.oschina.net/content/repositories/thirdparty/</url>
    </mirror>
</mirrors>

2) 在执行 Maven 命令的时候, Maven 还需要安装一些插件包,这些插件包的下载地址也让其指向 OSChina 的 Maven 地址

<profile>
    <id>jdk-1.4</id> 
    <activation>
        <jdk>1.4</jdk>
    </activation> 
    <repositories>
        <repository>
            <id>nexus</id>
            <name>local private nexus</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>local private nexus</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

3) 本地仓库修改

<localRepository>localRepositoryPath</localRepository>

四、IDE

1. IDE Maven设置

IDE的配置在:“File”-> “Setting” -> “Build,Execution,Deployment” -> “Build Tool” -> “Maven”中。
如果配置好了Maven的setting.xml文件,那么IDE中Maven的home directory、User Setting File 和Local repository 会从setting中读取,不需要修改。
另外,为了在打开Spark工程时,IDE自动下载依赖,需要在Importing中,将“Import Maven projects automatically”选项勾选上。

2. 打开Spark project

在IDE中打开Spark的pom文件,IDE会自动根据pom中的依赖下载依赖包,这些依赖包会存放到Local repository中。

3. IDE的一些小问题

如果在IDE中编写测试代码,运行时可能会遇到:

"scalac: bad option: -P:/home/jakub/.m2/repository/org/scalamacros/paradise_2.10.4/2.0.1/paradise_2.10.4-2.0.1.jar".

解决方法是,在File”-> “Setting” -> “Build,Execution,Deployment” -> “Build Tool” -> “Compiler” -> “Scala Compiler” 的选显卡中,清空 ”Additional compiler options“ 的内容,然后再次运行即可。

4. little tips

1) 遇到java和scala相互转化的问题
import scala.collection.JavaConversion._
2) RDD[K,V] 向PairRDDFuctions
需要应用SparkContext,sc中定义了隐式的转换

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值