gpt4 book ai didi

scala - Akka中 Unresolved 依赖项错误

转载 作者:行者123 更新时间:2023-12-04 10:00:07 26 4
gpt4 key购买 nike

嗨,我是akka的新手,我正在尝试开发示例akka应用程序
但是,当我在shell上执行运行命令时,它会给我 Unresolved 依赖项警告,然后显示错误

这是我的Main.scala文件

import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
 
class HelloActor extends Actor {
  def receive = {
    case "hello" => println("hello back at you")
    case _       => println("huh?")
  }
}
 
object Main extends App {
  val system = ActorSystem("HelloSystem")
  // default Actor constructor
  val helloActor = system.actorOf(Props[HelloActor], name = "helloactor")
  helloActor ! "hello"
  helloActor ! "buenos dias"
}

build.sbt
name := "tryakka"

version := "1.0"

scalaVersion := "2.11.1"

resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"

以下是警告和错误
[warn]  module not found: com.typesafe.akka#akka-actor_2.11.1;2.3.4
[warn] ==== local: tried
[warn] /home/ahsen/.ivy2/local/com.typesafe.akka/akka-actor_2.11.1/2.3.4/ivys/ivy.xml
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/akka/akka-actor_2.11.1/2.3.4/akka-actor_2.11.1-2.3.4.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11.1/2.3.4/akka-actor_2.11.1-2.3.4.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.11.1;2.3.4: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/ahsen/SbtPrctc/tryakka/}default-240ba8/*:update: sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.11.1;2.3.4: not found

提前致谢

最佳答案

当前,您需要的依赖项是:

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.4"

它是为Scala 2.11版而非2.11.1版构建的。您的依赖项使用 %%替代了构建中设置的Scala版本,因此出现错误-您的URL包含次要版本,并且该资源不存在。

更新:

我创建了一个小项目,其中包含可编译和运行的代码。在这里查看: https://github.com/izmailoff/SmallAkkaProjectExample

关于scala - Akka中 Unresolved 依赖项错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24931902/

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