
2. 创建新的project文件夹
3. project目录下创建项目配置文件Build.scala和build.properties
4. 运行sbt reload,update,compile编译项目
5. sbt eclipse create-src创建eclipse项目
6. Eclipse中导入akka项目
第一部分、软件安装1、 安装JDK (版本为1.7.0_11)
2、 安装Scala (版本为2.11.2)
3、 安装ScalaIDE(版本为3.0.4)
第二部分:加压缩官网下载的源代码包或者找到通过Git抽取的Spark源文件:
我用的是spark-1.1.1版本(最新版本),由于idea 13已经原生支持sbt,所以无须为idea安装sbt插件。
源码下载(用git工具):
# Masterdevelopment branch
gitclone git://github.com/apache/spark.git
# 1.1 maintenancebranch with stability fixes on top of Spark 1.1.1
gitclone git://github.com/apache/spark.git -b branch-1.1
源码更新(用git工具同步跟新源码):
gitclone https://github.com/apache/spark.git
第三部分:通过sbt工具,构建Scala的Eclipse工程,详细步骤如下所示
1、通过cmd命令进入DOS界面,之后通过cd命令进入源代码项目中,我下载的Spark.1.1.1版本的源代码放在(E:\Spark计算框架的研究\spark_1_1_1_eclipse)文件夹中,之后运行sbt命令,如下所示:
2、运行sbt命令之后,解析编译相关的jar包,并出现sbt命令界面窗口,出现的效果图如下所示,之后运行eclipse命令,sbt对这个工程进行编译,构建Eclipse项目,效果图如下所示:
4、 打开ScalaIDE工具,File à Import à Existing Projects into Workspace à
Next à
选择刚好用sbt工具编译好的Eclipse工程(E:\Spark计算框架的研究\spark_1_1_1_eclipse),如下图所示。
5、 通过上面的 *** 作,就可以将通过sbt工具编译生成的Eclipse项目导入到EclipseIDE开发环境中,效果图如下所示:
错误提示如下所示:我导入的包为,如下文件夹中所示。
(E:\Spark计算框架的研究\spark_1_1_1_eclipse\lib_managed\bundles)
Description Resource Path Location Type
akka-remote_2.10-2.2.3-shaded-protobuf.jar is cross-compiled
with an incompatible version of Scala (2.10).
In case of errorneous report, this check can be disabled
in the compiler preference page.
spark-core Unknown Scala Classpath Problem
Description Resource Path Location Type
akka-slf4j_2.10-2.2.3-shaded-protobuf.jar is cross-compiled with
an incompatible version of Scala (2.10). In case of errorneous report,
this check can be disabled in the compiler preference page.
spark-core Unknown Scala Classpath Problem
Description Resource Path Location Type
akka-testkit_2.10-2.2.3-shaded-protobuf.jar is cross-compiled
with an incompatible version of Scala (2.10).
In case of errorneous report, this check can be disabled in the compiler preference page.
spark-core Unknown Scala Classpath Problem
Description Resource Path Location Type
akka-zeromq_2.10-2.2.3-shaded-protobuf.jar is cross-compiled
with an incompatible version of Scala (2.10).
In case of errorneous report, this check can be disabled in the compiler preference page.
spark-core Unknown Scala Classpath Problem
上面这些包兼容性问题还没有解决,修改相应的jar包就可以解决。
1)新建一个目录叫 test2)在test目录中新建文件build.sbt
3)在test目录新建project目录,进入project目录,并新建plugins.sbt,在其中添加
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
4)在build.sbt中配置工程的name,scala编译环境,依赖等等。如:
import sbt._
import Process._
import Keys._
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource
lazy val commonSettings = Seq(
name := "test",
organization := "com.marsyoung",
version := "0.0.1-SNAPSHOT",
scalaVersion := "2.11.7"
)
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"junit" % "junit" % "4.4",
"javax.ws.rs" % "jsr311-api" % "1.1.1"
)
)
5)在cmd中进入对应的project目录,即test目录。运行sbt。
6)执行eclipse命令,将对应的项目转化成可以引入eclipse开发工具并且目录结构类似maven的项目。
7)打开已经安装了scala ide的eclipse,导入对应的project,会自动的编译成scala peoject.
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)