Java 使用spray aws连接到spray框架下的DynamoDB时出错

Java 使用spray aws连接到spray框架下的DynamoDB时出错,java,scala,amazon-web-services,amazon-dynamodb,spray,Java,Scala,Amazon Web Services,Amazon Dynamodb,Spray,我正在编写一个使用scala+akka+spray的新服务器,我需要连接AWS中的DynamoDB。我做了一些研究,找到了你的lib“spray aws”。但是当我尝试使用它时,我犯了一些错误。。scala版本2.11.2,sbt版本应为0.13.1 $ sbt > re-start [info] Compiling 6 Scala sources to /home/ubuntu/dc-judi-server-scala/target/scala-2.11/classes... [err

我正在编写一个使用scala+akka+spray的新服务器,我需要连接AWS中的DynamoDB。我做了一些研究,找到了你的lib“spray aws”。但是当我尝试使用它时,我犯了一些错误。。scala版本2.11.2,sbt版本应为0.13.1

$ sbt
> re-start

[info] Compiling 6 Scala sources to /home/ubuntu/dc-judi-server-scala/target/scala-2.11/classes...
[error] /home/ubuntu/dc-judi-server-scala/src/main/scala/com/example/Boot.scala:13: object dynamodb is not a member of package com.sclasen.spray.aws
[error] import com.sclasen.spray.aws.dynamodb
[error]        ^
[error] /home/ubuntu/dc-judi-server-scala/src/main/scala/com/example/Boot.scala:27: not found: value DynamoDBClientProps
[error]   val props = DynamoDBClientProps("xxx", "yyy", Timeout(100 seconds), dbsystem, dbsystem)
[error]               ^
[error] /home/ubuntu/dc-judi-server-scala/src/main/scala/com/example/Boot.scala:28: not found: type DynamoDBClient
[error]   val client = new DynamoDBClient(props)
[error]                    ^
[error] three errors found
[error] (compile:compile) Compilation failed
[error] Total time: 25 s, completed Aug 21, 2014 4:30:42 AM
附件是my build.sbt和Boot.scala 我对这个框架非常陌生,没有太多的经验。你能帮助我,给我一些见解吗。。? 非常感谢

organization  := "com.example"

version       := "0.1"

scalaVersion  := "2.11.2"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  val akkaV = "2.3.5"
  val sprayV = "1.3.1"
  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-slf4j"    % akkaV,
    "com.typesafe.slick"  %%  "slick"         % "2.1.0",
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test",
    "org.specs2"          %%  "specs2-core"   % "2.3.11" % "test",
    "mysql"               %   "mysql-connector-java" % "5.1.32",
    "ch.qos.logback"      %   "logback-classic" % "1.1.1",
    "com.sclasen"         %   "spray-aws_2.11"  % "0.3.4"
  )
}

resolvers ++= Seq(
    "Spray repository" at "http://repo.spray.io",
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

Revolver.settings
organization  := "com.example"

version       := "0.1"

scalaVersion  := "2.11.2"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

libraryDependencies ++= {
  val akkaV = "2.3.5"
  val sprayV = "1.3.1"
  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-slf4j"    % akkaV,
    "com.typesafe.slick"  %%  "slick"         % "2.1.0",
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test",
    "org.specs2"          %%  "specs2-core"   % "2.3.11" % "test",
    "mysql"               %   "mysql-connector-java" % "5.1.32",
    "ch.qos.logback"      %   "logback-classic" % "1.1.1",
    "com.sclasen"         %   "spray-aws_2.11"  % "0.3.4"
  )
}

resolvers ++= Seq(
    "Spray repository" at "http://repo.spray.io",
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

Revolver.settings
包com.example

import akka.actor.{ActorSystem, Props}
import akka.io.IO
import spray.can.Http
import akka.pattern.ask
import akka.util.Timeout
import scala.concurrent.duration._
import com.example.config.Configuration
import com.example.service._


import com.sclasen.spray.aws.dynamodb
import concurrent.Await
import concurrent.duration._
import com.amazonaws.services.dynamodbv2.model.ListTablesRequest

object Boot extends App with Configuration {

  // we need an ActorSystem to host our application in
  implicit val system = ActorSystem("on-spray-can")

  // A new actor system for host DB
  import com.sclasen.spray.aws._

  val dbsystem = ActorSystem("test")
  val props = DynamoDBClientProps("xxx", "yyy", Timeout(100 seconds), dbsystem, dbsystem)
  val client = new DynamoDBClient(props)
  try {
    val result = Await.result(client.sendListTables(new ListTablesRequest()), 100 seconds)
    println(result)
    result.getTableNames.size() should be >= 1
  } catch {
    case e: Exception =>
      println(e)
      e.printStackTrace()
  }

  // create and start our service actor
  val service = system.actorOf(Props[CustomerServiceActor], "demo-service")

  implicit val timeout = Timeout(5.seconds)
  // start a new HTTP server on port 80 with our service actor as the handler
  IO(Http) ? Http.Bind(service, host, port)
}
更新: 我已尝试将导入更改为:import com.sclasen.spray.aws_


但是仍然找不到DynamoDBClientProps和DynamoDBClient…

在build.sbt中,更改为:

"com.sclasen"         % "spray-dynamodb" % "0.3.4" 
在Boot.scala中,直接导入此2:

import com.sclasen.spray.aws.dynamodb.DynamoDBClient
import com.sclasen.spray.aws.dynamodb.DynamoDBClientProps