我正在使用Scala,Play Framework和IntelliJ IDE开发一个后端项目来练习,我是这些技术的新手。
我将Reactive Mongo依赖项添加到build.sbt
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.12.6-play26"
)
我得到的是这个错误:
No implementation for play.modules.reactivemongo.ReactiveMongoApi was bound
当我将鼠标悬停在
上时"org.reactivemongo" %% "play2-reactivemongo" % "0.12.6-play26"
这个小文字显示:
未知的神器。未解决或编入索引。
我做错了什么?
更新
当我通过点击选项+输入依赖项刷新项目时,“事件日志”显示:
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [warn] * com.google.guava:guava:22.0 is selected over 19.0 [warn] +- com.typesafe.play:play_2.12:2.6.7 (depends on 22.0) [warn] +- com.google.inject:guice:4.1.0 (depends on 19.0) [warn] * com.typesafe.akka:akka-stream_2.12:2.5.6 is selected over 2.4.19 [warn] +- com.typesafe.play:play-streams_2.12:2.6.7 (depends on 2.5.6) [warn] +- com.typesafe.akka:akka-http-core_2.12:10.0.10 (depends on 2.4.19) [warn] * com.typesafe.akka:akka-actor_2.12:2.5.6 is selected over {2.4.14, 2.4.19} [warn] +- com.typesafe.akka:akka-stream_2.12:2.5.6 () (depends on 2.5.6) [warn] +- com.typesafe.play:play_2.12:2.6.7 (depends on 2.5.6) [warn] +- com.typesafe.akka:akka-slf4j_2.12:2.5.6 () (depends on 2.5.6) [warn] +- com.typesafe.akka:akka-parsing_2.12:10.0.10 (depends on 2.4.19) [warn] +- org.reactivemongo:reactivemongo_2.12:0.12.6 () (depends on 2.4.14) [warn] Run 'evicted' to see detailed eviction warnings
答案 0 :(得分:2)
Maven Central Repository中发布的插件没有0.12.6-play26
版本。您可能需要版本0.12.7-play26
:
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.12.7-play26"
)
答案 1 :(得分:2)
这看起来像依赖注入的错误。您是否完全关注了您引用的tutorial,包括"设置"一部分?
因此,可以配置依赖注入,以便为您的控制器提供新的ReactiveMongo API。首先,将下面的行添加到application.conf:
play.modules.enabled += "play.modules.reactivemongo.ReactiveMongoModule"
答案 2 :(得分:0)
首先请确保将其添加到build.sbt:
routesGenerator := InjectedRoutesGenerator
没有这个,控制器是静态的,不会进行依赖注入。 然后,我遇到了与您相同的问题,这是因为application.conf上的配置错误。我觉得当配置不好时,尝试创建mongo API实例时会出现静默错误,然后也无法注入控制器。