ããæ¬æåææ¯å·²ç»æ£ç¡®å®è£
好scala,sbt以åsparkäº ç®è¿°å°ç¨åºæè½½å°é群ä¸è¿è¡çæ¥éª¤ï¼
ãã1ãæ建sbtæ åç项ç®å·¥ç¨ç»æï¼SBT项ç®å·¥ç¨ç»æå¾å
¶ä¸ï¼~/build.sbtæ件ç¨æ¥é
置项ç®çåºæ¬ä¿¡æ¯ï¼é¡¹ç®åãç»ç»åã项ç®çæ¬ã使ç¨çscalaçæ¬æè
å次é
ç½®äºé¡¹ç®æéçä¾èµå
ï¼ï¼project/build.propertiesæ件é
ç½®ä½ è¦ä½¿ç¨ä»ä¹çæ¬çsbt对项ç®æä½ï¼project/plugins.sbtæ件æ¯ç»é¡¹ç®æ·»å æéçæ件ï¼project/Build.scalaæ件æ¯å¯¹é¡¹ç®è¿è¡äºå¤æçé«çº§é
ç½®ï¼è¯¦ç»çsbtå®è£
é
ç½®å®ç¨åè§åæï¼
ãã2ãå°ç¸åºç®å½ä¸ç¼åç¨åºï¼sparkç¨åºå¿
é¡»è¦å建ä¸ä¸ªSparkContextå®ä¾ãSparkContext("master", "projectName", "SPARK_HOME", "yourProject.jar path")
ãã3ãsbt compileå½ä»¤ç¼è¯ç¨åºæ éåï¼sbt packageå½ä»¤å°ç¨åºæå
ãé»è®¤æå
çjaræ件åæ¾è·¯å¾ä¸ºï¼é¡¹ç®æ ¹ç®å½/target/scala-xx.xx.xx/your-project-name_xx.xx.xx-xx.jar
ãã4ãå°æå
好çjaré®ä»·æ·»å å°SPAK_CLASSPATHä¸ï¼å¨linuxä¸æ ¹æ®ä½ç¨èå´çä¸åæå¤ç§æ´æ¹ç¯å¢åéçæ¹å¼ï¼è¿éåªè¯´æçé
ç½®æ¹å¼ï¼sparkæ ¹ç®å½ä¸çconf/spark-env.shæ件添å SPARK_CLASSPATH:xxxxxxxxï¼
ãã5ãé
置好ç¯å¢åéåå°±å¯ä»¥å¨sparkçæ ¹ç®å½ä¸ä½¿ç¨./runèæ¬è¿è¡ä½ çç¨åºäºä¾å¦ï¼./run spark.examples.SparkPi spark://masterIP:port注æï¼å¦æç¨åºæ¶åIOæä½èµ·é»è®¤è·¯å¾ä¸ºSPARK_HOMEï¼è³äºå¦ä½ä¿®æ¹è¿ä¸ªè·¯å¾ï¼æå¾
ç 究
转载ï¼ä»
ä¾åèã
温馨提示:答案为网友推荐,仅供参考