【发布时间】:2018-05-02 06:31:27
【问题描述】:
我在一个 Scala 项目中使用 Akka Streams API,在 Intellij IDEA 中使用 SBT 插件工作。我有一个工作池流,如下所述:https://doc.akka.io/docs/akka/current/scala/stream/stream-cookbook.html。这是我的代码:
package streams
import akka.NotUsed
import akka.stream.scaladsl.{Balance, Flow, GraphDSL, Merge}
import akka.stream.{FlowShape, Graph}
object WorkerPoolFlow {
def apply[In, Out](
worker: Flow[In, Out, Any],
workerCount: Int):
Graph[FlowShape[In, Out], NotUsed] = {
GraphDSL.create() { implicit b =>
val balance = b.add(Balance[In](workerCount, waitForAllDownstreams = true))
val merge = b.add(Merge[Out](workerCount))
for (i <- 0 until workerCount)
balance.out(i) ~> worker.async ~> merge.in(i)
FlowShape(
balance.in,
merge.out)
}
}
}
由于某种原因,项目现在无法编译,出现以下错误:value ~> is not a member of akka.stream.Outlet[In]。
直到今天它编译得很好。我知道的唯一改变是安装一个 Scala linter 插件scalafmt,并在build.sbt 中导入一些新库。这是我的build.sbt:
name := "myProject"
version := "0.1"
scalaVersion := "2.11.11"
unmanagedJars in Compile += file("localDep1.jar")
unmanagedJars in Compile += file("localDep2.jar")
libraryDependencies += "io.spray" %% "spray-json" % "1.3.3"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.6"
libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.5.6"
libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.5.6" % Test
libraryDependencies += "com.typesafe.akka" %% "akka-stream-testkit" % "2.5.6" % Test
libraryDependencies += "com.47deg" %% "fetch" % "0.6.0"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
我尝试过重新加载 SBT、在 IDEA 之外从 SBT 构建、删除和重新添加依赖项以及清理项目,但没有成功。
【问题讨论】:
标签: scala intellij-idea sbt akka akka-stream