1

当我尝试扩展 SalatDAO 或使用 grater[T].asObject(x) 时出现以下错误:

SalatDAO 所需的类文件丢失。com.mongodb.casbah.TypeImports 的引用类型 MongoCollection 引用不存在的符号。

我遵循了 Salat 示例,但由于某种原因,扩展 SalatDAO 和 graters 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 compile 进行编译。这是我的 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"
4

1 回答 1

1

看起来您可能使用的是旧版本的 Salat。尝试将您的版本更改为以下版本:

“com.novus”%%“salat-core”%“0.0.8-SNAPSHOT”

或者

“com.novus”%“salat-core_2.9.1”%“0.0.8-SNAPSHOT”

于 2012-04-04T12:50:37.840 回答