Search code examples
scalamongodbcasbah

Cannot get a basic Casbah 3.0 program to compile


My project uses the following jars: scala-library (2.9.2), mongo-java-driver (2.7.3), scalaj-collection (2.9.1-1.2), casbah (util, commons, core, query, gridfs) 2.9.1-3.0.0-M2, joda-time 2.1, and joda convert 1.2

When I enter the following hello-worldish code:

package test

import com.mongodb.casbah.Imports._

object Test {
  def main(args: Array[String]): Unit = {
    var connection = MongoConnection()
  }
}

I get an error: "not found: value MongoConnection". The error goes away if I explicitly

include com.mongodb.casbah.MongoConnection

But I thought Imports._ was supposed to be taking care of that. What could I be doing wrong?


Solution

  • In Casbah 3.0, Imports._ is deprecated. What is weird though is that MongoConnection is not even imported anymore. Everything else works but deprecation warnings occur.

    As those warnings state, you just need to do this instead:

    import com.mongodb.casbah._