阿卡流 2.6。如何创建 ActorMaterializer?

Akka stream 2.6. How to create ActorMaterializer?

从 2.6 开始,我在这一行收到弃用警告:

import akka.stream.ActorMaterializer
implicit val actorMaterializer = ActorMaterializer()

警告:

method apply in object ActorMaterializer is deprecated (since 2.6.0): Use the system wide materializer with stream attributes or configuration settings to change defaults

我不明白那条消息,我该怎么办?什么是 'system wide materializer',它位于某个 akka 包中?

不再需要了。但是您必须在您的上下文中提供 implicitActorSystem

implicit val actorSystem = ActorSystem()

然后在akka.stream.Materializer

中从ActorSystem隐式派生物化器
  /**
   * Implicitly provides the system wide materializer from a classic or typed `ActorSystem`
   */
  implicit def matFromSystem(implicit provider: ClassicActorSystemProvider): Materializer =
    SystemMaterializer(provider.classicSystem).materializer