当我尝试扩展SalatDAO或使用grater [T] .asObject(x)时,我收到以下错误:
缺少SalatDAO所需的类文件。引用类型MongoCollection com.mongodb.casbah.TypeImports指的是不存在的符号。
我遵循了Salat的例子,但由于某种原因,延伸SalatDAO和磨刀石asObject对我不起作用。我在网上找不到任何对此错误的引用。
这是我的代码:
import net.trevor.model.DBConnection._
import com.novus.salat._
import com.novus.salat.global._
import com.mongodb.casbah.Imports._
import com.novus.salat.dao.SalatDAO
//error occurs on following line:
object HandleDAO extends SalatDAO[Handle, ObjectId](DBConnection.db("Handles")){
def getHandleAsDBObject(handle : Handle) : DBObject =
grater[Handle].asDBObject(handle)
def getHandleFromDBObject(dbObject : DBObject) : Handle =
//error occurs on following line:
grater[Handle].asObject(dbObject)
}
我真的很感激任何帮助或建议。我是Scala和Mongodb的新手。
我正在使用sbt编译进行编译。这是我的build.sbt
name := "handle_engine"
version := "1.0"
scalaVersion := "2.9.1"
scalacOptions += "-deprecation"
fork in run := true
resolvers ++= Seq(
"twitter-repo" at "http://maven.twttr.com",
"repo.novus rels" at "http://repo.novus.com/releases/",
"repo.novus snaps" at "http://repo.novus.com/snapshots/",
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
)
libraryDependencies ++= {
val liftVersion = "2.4-M5" // Put the current/latest lift version here
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
"net.liftweb" %% "lift-amqp" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mongodb" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile->default",
"net.liftweb" %% "lift-wizard" % liftVersion % "compile->default")
}
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-server" % "8.1.0.RC5", // % "compile,jetty",
"org.eclipse.jetty" % "jetty-servlet" % "8.1.0.RC5", // % "compile,jetty",
"org.mongodb" % "mongo-java-driver" % "compile->default",
"com.rabbitmq" % "amqp-client" % "compile->default",
"org.mongodb" % "casbah_2.9.0-1" % "3.0.0-M2",
"com.novus" % "salat-core_2.8.1" % "0.0.7", //Salat for MongoDB and Casbah
"org.apache.avro" % "avro" % "1.6.2",
"com.twitter" % "util-core_2.9.1" % "1.12.8", "com.twitter" % "util-eval_2.9.1" % "1.12.8",
"junit" % "junit" % "4.5" % "test->default",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default",
"ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default"
)
seq(webSettings :_*)
libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.26" % "test,container"
libraryDependencies += "org.scala-tools.testing" %% "specs" % "1.6.9" % "test"
答案 0 :(得分:1)
看起来你可能会使用较旧版本的Salat。尝试将您的版本更改为以下内容:
“com.novus”%%“salat-core”%“0.0.8-SNAPSHOT”
或
“com.novus”%“salat-core_2.9.1”%“0.0.8-SNAPSHOT”