在Scala2.13.4/SBT1.2.8项目中,类MyService.scala具有以下导入:
import play.api.libs.concurrent.AkkaGuiceSupport我认为包含该类的库是由sbt作为我在build.sbt中作为libraryDependencies添加的一个库的依赖项添加的。
但是,当我编译该项目时,我得到:
$ sbt -java-home /usr/lib/jvm/java-8 -jvm-debug 9999 run
...
[info] Compiling 31 Scala sources and 1 Java source to /home/me/projects/my_project/target/scala-2.13/classes ...
[error] /home/me/projects/my_project/app/actors/MyService.scala:8:8: object AkkaGuiceSupport is not a member of package play.api.libs.concurrent
[error] import play.api.libs.concurrent.AkkaGuiceSupport
[error] ^在IntelliJ中,在项目的外部库中,我可以看到:

,我在这里错过了什么?
这个编译错误的原因是什么?
........................................................
更新:
build.sbt
name := "CH07"
version := "1.0"
lazy val `ch07` = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.13.4"
resolvers += "Spy Repository" at "http://files.couchbase.com/maven2"
libraryDependencies ++= Seq(
jdbc,
cacheApi,
ws,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.jooq" % "jooq" % "3.14.4",
"org.jooq" % "jooq-codegen-maven" % "3.14.4",
"org.jooq" % "jooq-meta" % "3.14.4",
"joda-time" % "joda-time" % "2.7",
"com.ning" % "async-http-client" % "1.9.29",
"com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
"com.typesafe.akka" %% "akka-persistence" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-query" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-typed" % "2.6.10"
)
routesGenerator := InjectedRoutesGeneratorproject/plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")project/build.properties
sbt.version=1.3.10发布于 2021-02-09 20:43:30
首先,您可以看到它,因为它是play框架的一部分。您可以在PlayImport中看到更多您没有导入的包,但它们是因为播放而出现的。例如,如果从jdbc中删除libraryDependencies,您可能会看到更多这样的错误(只是使用不同的包名,并且只在实际使用的情况下)。请注意,您将能够在IntelliJ树中找到缺少的类,而编译器不会。
在您的示例中,缺少的导入是guice。AkkaGuiceSupport是guice的一部分。尝试将其添加到库依赖项中:
libraryDependencies ++= Seq(
guice, // This is the missing part
jdbc,
cacheApi,
ws,
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
"org.hsqldb" % "hsqldb" % "2.5.0",
"org.jooq" % "jooq" % "3.14.4",
"org.jooq" % "jooq-codegen-maven" % "3.14.4",
"org.jooq" % "jooq-meta" % "3.14.4",
"joda-time" % "joda-time" % "2.7",
"com.ning" % "async-http-client" % "1.9.29",
"com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
"com.typesafe.akka" %% "akka-persistence" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-query" % "2.6.10",
"com.typesafe.akka" %% "akka-persistence-typed" % "2.6.10"
)https://stackoverflow.com/questions/65389252
复制相似问题