環境部署
安裝IntelliJ IDE
下載安裝即可 ,選擇Community版本
下載Spark源碼
cd /Users/jackli/Desktop/Pjt_idea/
git clone https://github.com/apache/spark
IntelliJ 安裝相關依賴
打開IntelliJ
Import Project ,選擇spark文件夾
選擇Import Project from external model , 選擇 SBT
選擇 finish
等待 30-60分鐘左右,下載相關依賴包。
退出IntelliJ IDE
安裝sbt
brew install sbt
sbt編譯
cd ~/spark
sbt package
需要2小時左右完成編譯,編譯完成後輸出如下信息
[info] Packaging /Users/jackli/Desktop/Pjt_idea/spark/examples/target/scala-2.11/jars/spark-examples_2.11-2.3.0-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 2433 s, completed 2017-6-20 21:20:13
此時後看到jar文件
cd /Users/jackli/Desktop/Pjt_idea/spark/assembly/target/scala-2.11/jars/
ls
程序開發
創建WordCount項目
Create a Project
選擇 IDEA
Project name - “WordCount”
導入jar包
File - Project Structure - Libraries - 選擇jar目錄位置 ,OK ,OK確認
導入完成後項目裏可看到jar包
編寫代碼
新建scala文件
編寫代碼
運行
運行配置
運行
Run - Run WordCount