/ /スプレー依存性エラー - スカラ、intellij-idea、akka、scala-2.10、スプレー

スプレー依存性エラー - スカラ、intellij-idea、akka、scala-2.10、スプレー

私はスプレーのドキュメントで「最小限の例題」を実行しようとしています: スプレー1.2-RC2>ルーティング

私はscala 2.10.3を使用しています。これは、Dependencies.scalaファイルに記述されている私の設定の一部です:

val sprayVersion = "1.2-RC2"
val sprayCan     = "io.spray"           %    "spray-can"     % sprayVersion
val sprayRouting = "io.spray"           %    "spray-routing" % sprayVersion
val sprayJson    = "io.spray"           %%   "spray-json"    % "1.2.5"

val akkaVersion  = "2.2.3"
val akkaActor    = "com.typesafe.akka"  %%  "akka-actor"     % akkaVersion
val akkaSlf4j    = "com.typesafe.akka"  %%  "akka-slf4j"     % akkaVersion
val akkaTestKit  = "com.typesafe.akka"  %%  "akka-testkit"   % akkaVersion

そして、これは私の単純なコード例です:

import spray.routing.SimpleRoutingApp

object Main extends App with SimpleRoutingApp {
startServer(interface = "localhost", port = 8080) {
path("hello") {
get {
complete {
<h1>Say hello to spray</h1>
}
}
}
}
}

コンパイル時に次のエラーが発生する

bad symbolic reference. A signature in Http.class refers to term actor
in package akka which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling Http.class.
startServer(interface = "localhost", port = 8080) {
^

私は何が間違っているのか分かりません。

編集: 私はエラーがメソッドで使用されるHttp.Boundによって引き起こされると思う "s startServerを返す:

IO(Http).ask(Http.Bind(serviceActor, interface, port, backlog, options, settings)).mapTo[Http.Bound]

特に私はそれが輸入品だと思う akka.io.TcpHttp.scala あなたに問題を与える。 オン Akkaのドキュメント 私はより多くのIOがakka 2.2.0から "実験的"としてマークされていることを読む

私はおかしくなりそうだ

回答:

回答№1は1

アクタークラス/オブジェクトの明示的なインポートを追加し、暗黙のアクターシステムvalを宣言してみてください。このような:

import spray.routing.SimpleRoutingApp
import akka.actor._

object Main 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>
}
}
}
}
}

また、Dependencies.scalaのどの部分がbuild.sbtによって選択されているかを確認する必要があります。 Dependencies.scalaファイルを削除し、このようにbuild.sbtに依存関係を追加してみてください。

name := """spray-rest"""

version := "1.0"

scalaVersion := "2.10.3"

resolvers += "spray repo" at "http://repo.spray.io"

resolvers += "spray nightlies" at "http://nightlies.spray.io"

libraryDependencies ++= Seq(
"com.typesafe.akka"  %% "akka-actor"       % "2.2.3",
"com.typesafe.akka"  %% "akka-slf4j"       % "2.2.3",
"ch.qos.logback"      % "logback-classic"  % "1.0.13",
"io.spray"            % "spray-can"        % "1.2-RC2",
"io.spray"            % "spray-routing"    % "1.2-RC2",
"io.spray"           %% "spray-json"       % "1.2.3",
"org.specs2"         %% "specs2"           % "1.14"         % "test",
"io.spray"            % "spray-testkit"    % "1.2-RC2" % "test",
"com.typesafe.akka"  %% "akka-testkit"     % "2.2.3"        % "test",
"com.novocode"        % "junit-interface"  % "0.7"          % "test->default"
)

scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-Ywarn-dead-code",
"-language:_",
"-target:jvm-1.7",
"-encoding", "utf-8"
)

testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")