1 下载好spark源码,解压
2 打开IDEA --> 顶部工具栏【File】 --> 【New】 --> 【Project from Existing Sources】,然后
选择要导入的spark源码项目 ---> 【Next】, 出现下面的对话框
如图,需要勾选【Import Maven Projects automatically】,并选中需要要的JDK环境,这里我选择了JDK1.8
3 点击上图右下角的【Environment settings】,为该项目配置好Maven,注意Maven的版本是否满足需求
4 上一步完成后,点【Next】为编译spark源码工程,选择profiles
5 导入工程后,IDEA右侧边Maven窗口,最上一个profiles菜单,点开,再次检查一下需要的profiles
6 先选中这个Project,鼠标右键 ---> 【Maven】 --> 【Generate Sources and Update Folders】
7 顶部工具栏【Build】 --> 【Build Project】,等build过程中,看是否报错。如果报错,转到步骤6
8 将报错所属的module,依次执行如下操作:
a 鼠标单击选中,鼠标右键 ---> 【Maven】 --> 【Generate Sources and Update Folders】
都generate sources后,再次执行Build Project 就没啥问题了,可以愉快的debug源码了
参考资料
【1】 http://spark.apache.org/docs/latest/building-spark.html#intellij-idea-or-eclipse
【2】https://spark.apache.org/developer-tools.html 找到 IDE Setup 部分