I have the following code:
package db
import com.mongodb.casbah.{ MongoCollection, MongoConnection, MongoDB }
import com.mongodb.casbah.commons.{ MongoDBObject }
object Test {
def main(argc: Array[String]) {
val db 开发者_StackOverflow社区= MongoDB(MongoConnection(), "test")
val objText = MongoDBObject("user" -> "This the text is test number the two")
val coll = db.getCollection("coll_tet")
coll.insert(objText)
print(coll.find())
}
}
And I do scalac -classpath ... test.scala
When I tried to run this: scala db.Test -classpath ...
I'm get an error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/Mongo
Why is this happening?
Why don't you just add the Imports
object?
import com.mongodb.casbah.Imports._
And it should take care of all your import problems.
精彩评论