开发者

error of run scala code

开发者 https://www.devze.com 2023-03-05 19:20 出处:网络
I have the following code: package db import com.mongodb.casbah.{ MongoCollection, MongoConnection, MongoDB }

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消