小编Yin*_*ang的帖子

java.lang.NoSuchMethodError: 'void akka.actor.ExtensionId.$init$(akka.actor.ExtensionId)'

我只是想使用 akka 在 scala 项目中实现一个小示例 REST 端点。代码如下

import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{ContentTypes, HttpEntity}

import akka.actor.typed.ActorSystem
import akka.actor.typed.scaladsl.Behaviors
import scala.io.StdIn

import scala.concurrent.ExecutionContextExecutor


object ViewAPI :
  @main def run(): Unit = {
    implicit val system = ActorSystem(Behaviors.empty, "my-system")
    implicit val executionContext = system.executionContext
    val route =
      path("hello") {
        get {
          complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
        }
      }
    val bindingFuture = Http().newServerAt("localhost", 9001).bind(route)

  }
Run Code Online (Sandbox Code Playgroud)

我的 sbt 文件如下所示:

libraryDependencies += ("com.typesafe.akka" %% "akka-http" % "10.2.9").cross(CrossVersion.for3Use2_13)

libraryDependencies += "com.typesafe.akka" %% "akka-actor-typed" % "2.6.19"

libraryDependencies += "com.typesafe.akka" …
Run Code Online (Sandbox Code Playgroud)

scala akka akka-stream akka-http scala-3

3
推荐指数
1
解决办法
501
查看次数

标签 统计

akka ×1

akka-http ×1

akka-stream ×1

scala ×1

scala-3 ×1