Eclipse ä¸å¼åè°è¯ç¯å¢çé
ç½®
该å°èä¸ä½¿ç¨çå项工å
·åå«ä¸ºï¼Windows 7+Eclipse Java EE 4.4.2+Scala 2.10.4+Sbt 0.13.8+Maven3.3.3ï¼æµè¯ç Spark çæ¬ä¸º 1.4.0ã
1.é
ç½® IDEï¼
éæ©èå项 Help->Install new softwareï¼æ·»å ç«ç¹ ï¼éæ©å®è£
Scala IDE for Eclipse 以å Scala IDE Pluginsã
对äºæ åç Eclipseï¼è¿éè¦å®è£
åç¬ç Maven æ件ã
åºäºé
ç½®ç®ä¾¿èèï¼ä¹å¯ä»¥ä½¿ç¨ Scala å®æ¹æä¾çå·²å°ææä¾èµæå
好ç Scala IDEã
ç¹å«çï¼ç±äºé¡¹ç®æ¬èº«åå¨ä¸äºé误ï¼è¯·å
ææ¶å
³é Project->Build Automatically çåè½ä»¥èçæ¶é´ã
2.ä¸è½½ Spark æºä»£ç ï¼
å建空ç®å½ï¼æ§è¡å¦ä¸è¯å¥ï¼git clone
é¤äºä½¿ç¨ git æ令ä¹å¤ï¼ä¹å¯ä»¥ä» Spark ç Github 页é¢ä¸è½½æå
好çæºä»£ç ã
3.å°æºç 转å为 Eclipse 项ç®ï¼
è¿å
¥æºä»£ç æ ¹ç®å½ï¼æ§è¡å¦ä¸è¯å¥ï¼sbt eclipseãSbt æ§è¡æé´ä¼ä¸è½½ Spark æéè¦çææ jar å
ï¼å æ¤è¯¥æ¥éª¤ä¼è±è´¹å¾é¿çæ¶é´ãå
¶ä¸æä¸äº jar å
éè¦ä½¿ç¨ç½ç»ä»£ççæ¹æ³æè½ä¸è½½ã
4.导å
¥é¡¹ç®è³ Eclipseï¼
éæ©èå项 File->Importï¼å¹¶éæ© General->Existing Projects into Workspaceï¼é¡¹ç®çæ ¹è·¯å¾éæ©æºä»£ç çæ ¹è·¯å¾ï¼å¯¼å
¥ææ项ç®ï¼å
±æ 25 个ï¼ã
5.ä¿®æ¹ Scala çæ¬ï¼
è¿å
¥ Preference->Scala->Installationsï¼æ·»å æºå¨ä¸å®è£
ç Scala 2.10.4ï¼éæ© lib ç®å½ï¼ãç±äºè¯¥çæ¬ Sparkï¼1.4.0ï¼æ¯å¨ Scala 2.10.4 çç¯å¢ä¸ç¼åçï¼éè¦å¨ Eclipse ä¸ä¿®æ¹é¡¹ç®ä½¿ç¨ç Scala çæ¬ãæ¹æ³ä¸ºï¼å
¨é项ç®ï¼å³é®éæ© Scala->Set the Scala Installation 并éæ©ç¸åºç Scala çæ¬ã
6.为 old-deps 项ç®æ·»å Scala Libraryï¼
å³é®éæ© old-deps 项ç®ï¼éæ© Scala->Add Scala Library to Build Pathã
7.Maven install 以çæ spark-streaming-flume-sink æéè¦çç±»ï¼
é¦å
å°æºä»£ç æ ¹ç®å½ä¸ç scalastyle-config.xml æ件å¤å¶å° spark-streaming-flume-sink 项ç®æ ¹ç®å½ä¸ï¼èåå¨ Eclipse ä¸æå¼è¯¥é¡¹ç®ï¼å³é®éæ© pom.xml æ件ï¼éæ© Run as->Maven installã
8.ä¿®æ¹ spark-sql ä¸ spark-hive çå
é误ï¼
ç±äºæºä»£ç çå
设置æé误ï¼ä¸ºæ¤éè¦å°ç±»æ件移è³æ£ç¡®çå
ä¸
å¯¹äº spark-sql 项ç®ï¼åå«éæ© src/test/java ä¸ç test.org.apache.spark.sql 以å test.org.apache.spark.sql.sources å
ä¸çææç±»ï¼å³é®éæ© Refactor->Moveï¼ç§»å¨è³ org.apache.spark.sql 以å org.apache.spark.sql.sources å
ã
å¯¹äº spark-hive 项ç®ï¼åå«éæ© src/test/java ä¸ç test.org.apache.spark.sql.hive 以å test.org.apache.spark.sql.hive.execution å
ä¸çææç±»ï¼ç§»å¨è³ org.apache.spark.sql.hive 以å org.apache.spark.sql.hive.execution å
ã
9.ç¼è¯ææ项ç®ï¼
æå¼ Project->Build Automatically åè½ï¼çå¾
ææ项ç®ç¼è¯æåã
10.æ£æ¥æ¯å¦å®è£
æåï¼
å° core 项ç®ä¸ç src->main->resources->org æ件夹æ·è´å° examples 项ç®ä¸ç target->scala-2.10->classes ä¸ãèåæ§è¡ examples 项ç®ä¸ç org.apache.spark.examples.SparkPi ç¨åºï¼å¹¶è®¾ç½®å
¶ jvm åæ°ä¸º-Dspark.master=local
温馨提示:答案为网友推荐,仅供参考