Итак, я пытаюсь просто подключиться к MongoDB (dockerized) с помощью драйвера scala MongoDB из приложения Scalatra
build.sbt :
"org.mongodb.scala" %% "mongo-scala-driver" % "2.4.1"
ScalatraBootstrap.scala :
import org.scalatra._
import javax.servlet.ServletContext
import org.mongodb.scala.{MongoClient, MongoClientSettings, MongoDatabase, ServerAddress}
import collection.JavaConverters._
class ScalatraBootstrap extends LifeCycle {
override def init(context: ServletContext) {
val settings: MongoClientSettings = MongoClientSettings.builder()
.applyToClusterSettings(b => b.hosts(List(new
ServerAddress("localhost")).asJava))
.build()
val mongoClient: MongoClient = MongoClient(settings)
val database: MongoDatabase = mongoClient.getDatabase("db")
}
}
Все настройки соединения начинаются с http://mongodb.github.io/mongo-scala-driver/2.4/getting-started/quick-tour/
Но когда я пытаюсь запустить это, я получаю исключение:
java.lang.NoSuchMethodError: com.mongodb.connection.ClusterSettings$Builder.applySettings(Lcom/mongodb/connection/ClusterSettings;)Lcom/mongodb/connection/ClusterSettings$Builder;
at com.mongodb.MongoClientSettings$Builder.<init>(MongoClientSettings.java:167)
at com.mongodb.MongoClientSettings$Builder.<init>(MongoClientSettings.java:134)
at com.mongodb.MongoClientSettings.builder(MongoClientSettings.java:126)
at com.mongodb.async.client.MongoClientSettings$Builder.<init>(MongoClientSettings.java:99)
at com.mongodb.async.client.MongoClientSettings$Builder.<init>(MongoClientSettings.java:88)
at com.mongodb.async.client.MongoClientSettings.createFromClientSettings(MongoClientSettings.java:80)
at com.mongodb.async.client.MongoClients.create(MongoClients.java:161)
at org.mongodb.scala.MongoClient$.apply(MongoClient.scala:120)
at org.mongodb.scala.MongoClient$.apply(MongoClient.scala:103)
at ScalatraBootstrap.init(ScalatraBootstrap.scala:13)