scala的spray库,构建一个简单的Rest服务,获取源代码:https://github.com/spray/spray-template
加载SBT,命令:sbt
运行测试用例:test
启动服务:re-start
停止服务:re-stop
tips:build.sbt 已配置 Revolver.settings,可使用命令:re-start和re-stop,详细参考 sbt-revolver。即是build.sbt里添加了revoler.settings,同时pugins.sbt添加了addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")。
1.build.sbt文件内容
organization := "com.example"
version := "0.1"
scalaVersion := "2.11.2"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
libraryDependencies ++= {
val akkaV = "2.3.6"
val sprayV = "1.3.2"
Seq(
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"io.spray" %% "spray-testkit" % sprayV % "test",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test",
"org.specs2" %% "specs2-core" % "2.3.11" % "test"
)
}
Revolver.settings
2.pugins.sbt文件内容
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")