我正在尝试使用spala 2.11喷涂一个简单的“hello world”服务器:
import spray.routing.SimpleRoutingApp
import akka.actor.ActorSystem
object SprayTest extends App with SimpleRoutingApp {
implicit val system = ActorSystem("my-system")
startServer(interface = "localhost", port = 8080) {
path("hello") {
get {
complete {
<h1>Say hello to spray</h1>
}
}
}
}
}
但是,我收到以下编译错误:
Multiple markers at this line
- not found: value port
- bad symbolic reference to spray.can encountered in class file 'SimpleRoutingApp.class'. Cannot
access term can in package spray. The current classpath may be missing a definition for spray.can, or
SimpleRoutingApp.class may have been compiled against a version that's incompatible with the one
found on the current classpath.
- not found: value interface
有谁知道可能是什么问题?顺便说一下,我对喷雾和演员都很陌生,所以我对喷雾和演员的工作方式缺乏很多直觉(这就是为什么我要做这个简单的教程)。
答案 0 :(得分:5)
终于找到了自己的答案。我需要在我的pom文件中添加spray-can依赖项。留下这个问题和答案,以防其他人遇到同样的问题。
SBT示例:
scalaVersion := "2.10.4"
val akkaVersion = "2.3.6"
val sprayVersion = "1.3.2"
resolvers ++= Seq(
"Spray Repository" at "http://repo.spray.io/"
)
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"io.spray" %% "spray-can" % sprayVersion,
"io.spray" %% "spray-routing" % sprayVersion
)