我發現了以下錯誤,當我嘗試擴展SalatDAO或使用磨碎器[T] .asObject(X):Salat錯誤:SalatDAO需要的類文件丟失。 com.mongodb.casbah.TypeImports的引用類型MongoCollection是指不存在的符號
class file needed by SalatDAO is missing. reference type MongoCollection of com.mongodb.casbah.TypeImports refers to nonexisting symbol.
我我們遵循了Salat的例子,但由於某種原因,將SalatDAO和graters擴展爲Object並不適合我。我無法在網上找到任何有關此錯誤的參考。
這裏是我的代碼:
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)
}
我真的很感激有這方面的幫助或建議。我是斯卡拉和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"
什麼是net.trevor.model.DBConnection?並檢查com.mongodb.casbah.MongoCollection是否在您的類路徑 – 2012-04-03 11:25:17
@SerJ de SuDDeN。謝謝您的幫助。 MongoCollection在類路徑上。 ** DBConnection.db(「Handles」)**與**'com.mongodb.casbah.MongoConnection(host,port).getDB(database)(「Handles」)'**'相同** – fin 2012-04-03 11:59:15
你是如何編譯這個?您是使用IDE還是從命令行編譯它?如果你是在命令行上執行它,你是否也可以發佈你正在使用的確切參數? – Ren 2012-04-03 15:14:16