gpt4 book ai didi

Scala 声称我正在使用不同版本的 Akka

转载 作者:行者123 更新时间:2023-12-02 03:04:49 24 4
gpt4 key购买 nike

View repository at this specific commit here

我正在组建一个小型 SBT 项目并学习如何使用 akka actor。我能够得到一个仅使用 akka 的简单示例,但是一旦我使用外部库,事情就会停止工作。我用这个得到了一个非常大的堆栈跟踪

objc[15196]: Class JavaLaunchHelper is implemented in both 
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (0x10cc6c4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10ccf84e0). One of the two will be used. Which one is undefined.
Detected java.lang.NoSuchMethodError error, which MAY be caused by incompatible Akka versions on the classpath. Please note that a given Akka version MUST be the same across all modules of Akka that you are using, e.g. if you use akka-actor [2.5.8 (resolved from current classpath)] all other core Akka modules MUST be of the same version. External projects like Alpakka, Persistence plugins or Akka HTTP etc. have their own version numbers - please make sure you're using a compatible set of libraries.
Uncaught error from thread [HelloSystem-akka.actor.default-dispatcher-4]: akka.actor.ActorCell.addFunctionRef(Lscala/Function2;)Lakka/actor/FunctionRef;, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for for ActorSystem[HelloSystem]
java.lang.NoSuchMethodError: akka.actor.ActorCell.addFunctionRef(Lscala/Function2;)Lakka/actor/FunctionRef;

我的依赖项如下所示:

  object v {
val akka = "2.5.8"
val scrape = "0.4.0"
}

val akka = Seq(
"com.typesafe.akka" %% "akka-actor" % v.akka,
"com.typesafe.akka" %% "akka-slf4j" % v.akka
)

val scrape = Seq(
"io.bfil" %% "scalescrape" % v.scrape
)

lazy val allDeps = akka ++ scrape

我正在使用this library也使用 akka 版本 5.8 那么有什么好处呢?这个矛盾的 akka actor 版本是从哪里来的?这是我的 build.sbt,其中包括我尝试使用的冲突管理器:

import Dependencies._

name := "sputnik-scraper"

version := "0.1"

scalaVersion := "2.12.4"

conflictManager := ConflictManager.strict

dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % "2.5.8"

lazy val root = (project in file(".")).settings(
libraryDependencies ++= allDeps
)

编辑:添加了 main 中的代码。

import akka.actor.{ActorSystem, Props}
import io.bfil.scalescrape.actor.ScrapingActor

object Main extends App {

val system = ActorSystem("HelloSystem")
// default Actor constructor
val helloActor = system.actorOf(Props[ExampleScraper], name = "helloactor")
helloActor ! "hello"
helloActor ! "buenos dias"
}


class ExampleScraper extends ScrapingActor {

private val baseUrl = "https://www.sputnikmusic.com/"

override def receive: Receive = {
case _ => grabMainTitle(baseUrl)
}

private def grabMainTitle(url: String) =
scrape {
get(url) { response =>
complete(doIt(response))
}
}

private def doIt(response: Any): Unit = {
println(response)
}
}

最佳答案

很有可能是由 scalescrape 中使用的 Akka-HTTP 版本 10.0.1 引起的与 Akka 2.5 不同步。这是最新版本 Akka-HTTP 10.0.5 的发行说明:

This is the fifth maintenance release of the Akka HTTP 10.0 series. It is primarily aimed at stability aligning the internals with the upcoming Akka 2.5 release. ...

您可能需要考虑将 Akka-HTTP 依赖项修改为更新版本的 Akka HTTP 10.0。目前最新版本是 10.0.11。

关于Scala 声称我正在使用不同版本的 Akka,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48363010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com