Search code examples
scalaakkaactorspray

Where I can find spray.can.Http class


I begin with spray.

When I try create new spray server like

  IO(Http) ! Http.Bind(service, interface = "0.0.0.0", port = scala.util.Properties.envOrElse("PORT", "8080").toInt)

I see that spray.can._ does not exit. My current version of spray is 1.3.0. Where I can found the Http class?

build.sbt

libraryDependencies += "io.spray" % "spray-can" % "1.3.0"

libraryDependencies += "io.spray" % "spray-routing_2.11" % "1.3.1"

libraryDependencies += "io.spray" % "spray-json_2.11" % "1.3.0"

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.3.8"

Solution

  • In the spray-can library. Here are the Spray dependencies out of one of my build.sbt files:

    libraryDependencies ++= Seq(
      "io.spray"    %% "spray-can"        % "1.3.1",
      "io.spray"    %% "spray-http"       % "1.3.1",
      "io.spray"    %% "spray-routing"    % "1.3.1",
      "io.spray"    %% "spray-client"     % "1.3.1",
      "io.spray"    %% "spray-testkit"    % "1.3.1"   % "test",
      "io.spray"    %% "spray-json"       % "1.2.6",
      ...
    )
    

    Note that generally the versions should all match, except for spray-json, which is independent. In general you should let SBT append the scala version using %% in this way.

    Note that in your dependencies you neither manually add the _2.11 to spray-can nor use %%, so it is not going to find the library, which has the scala version in its name. I'm pretty sure that's the source of your problem.

    BTW, the source for the 1.3.0 version of spray.can.Http is here.