嗨,我是akka的新手,正在尝试开发样本akka应用程序 但是当我在shell上执行run命令时,它会给我 Unresolved Dependencies 警告,然后显示错误
这是我的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
提前致谢
答案 0 :(得分:17)
目前您需要的依赖项是:
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.4"
它为Scala版本2.11而不是2.11.1构建的差异。您的依赖项使用%%
替换构建中的Scala版本集,因此错误 - 您的URL包含次要版本,并且此类资源不存在。
更新:
我创建了一个小项目,其中包含编译和运行的代码。请在此处查看:https://github.com/izmailoff/SmallAkkaProjectExample