0

I am trying to use alpakka-mongodb based on the docs.

My dependencies look like this:

  object Versions {
    val alpakkaMongo = "2.0.0"
    val akkaVersion = "2.5.31"
  }

  lazy val deps = Seq(
    "com.lightbend.akka" %% "akka-stream-alpakka-mongodb" % Versions.alpakkaMongo,
    "com.typesafe.akka" %% "akka-stream" % Versions.akkaVersion
  )

and, the dependency tree looks like this:

[info]   +-com.lightbend.akka:akka-stream-alpakka-mongodb_2.12:2.0.0 [S]
[info]   | +-com.typesafe.akka:akka-stream_2.12:2.5.31 [S]
[info]   | | +-com.typesafe.akka:akka-actor_2.12:2.5.31 [S]
[info]   | | | +-com.typesafe:config:1.3.3
[info]   | | | +-org.scala-lang.modules:scala-java8-compat_2.12:0.8.0 [S]
[info]   | | | 
[info]   | | +-com.typesafe.akka:akka-protobuf_2.12:2.5.31 [S]
[info]   | | +-com.typesafe:ssl-config-core_2.12:0.3.8 [S]
[info]   | | | +-com.typesafe:config:1.3.3
[info]   | | | +-org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2 [S]
[info]   | | | 
[info]   | | +-org.reactivestreams:reactive-streams:1.0.2
[info]   | | 
[info]   | +-org.mongodb:mongodb-driver-reactivestreams:1.12.0
[info]   |   +-org.mongodb:mongodb-driver-async:3.11.0
[info]   |   | +-org.mongodb:bson:3.11.0
[info]   |   | +-org.mongodb:mongodb-driver-core:3.11.0
[info]   |   |   +-org.mongodb:bson:3.11.0
[info]   |   |   
[info]   |   +-org.reactivestreams:reactive-streams:1.0.2
[info]   |   
[info]   +-com.typesafe.akka:akka-stream_2.12:2.5.31 [S]
[info]     +-com.typesafe.akka:akka-actor_2.12:2.5.31 [S]
[info]     | +-com.typesafe:config:1.3.3
[info]     | +-org.scala-lang.modules:scala-java8-compat_2.12:0.8.0 [S]
[info]     | 
[info]     +-com.typesafe.akka:akka-protobuf_2.12:2.5.31 [S]
[info]     +-com.typesafe:ssl-config-core_2.12:0.3.8 [S]
[info]     | +-com.typesafe:config:1.3.3
[info]     | +-org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2 [S]
[info]     | 
[info]     +-org.reactivestreams:reactive-streams:1.0.2

However, when I try doing import org.mongodb.scala.bson.codecs.DEFAULT_CODEC_REGISTRY, I get cannot resolve symbol mongodb

What am I doing wrong here? Appreciate the help!

irrelevantUser
  • 1,172
  • 18
  • 35
  • have you re-imported project from SBT in SBT tool window? Can you build from IDE or from command line? Try adding `libraryDependencies += "org.mongodb.scala" %% "mongo-scala-bson" % "1.0.0"` dependency. – Andrey May 29 '20 at 12:51
  • @Andrey Adding `"org.mongodb.scala" %% "mongo-scala-bson" % "4.0.3"` this helped move the problem a step further. Now the issue is that `DEFAULT_CODEC_REGISTRY` is not resolved – irrelevantUser May 29 '20 at 13:49
  • In mongo-scala-bson version >= 4.0.0 the DEFAULT_CODEC_REGISTRY is removed, see https://jira.mongodb.org/browse/JAVA-3609. Try `import org.mongodb.scala.bson.codecs.Registry.DEFAULT_CODEC_REGISTRY` instead? According to https://github.com/rozza/mongo-java-driver/pull/356/files#diff-09070991919e9053022ddd4d749f12a0R30 – yiksanchan May 29 '20 at 14:25

0 Answers0