加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 使用Akka进行sbt构建需要什么?

发布时间:2020-12-16 08:59:14 所属栏目:安全 来源:网络整理
导读:我试图从sbt使用 scala -akka. 我的sbt文件如下所示: name := "hello"version := "1.0"scalaVersion := "2.9.1"resolvers += "akka" at "http://repo.akka.io/snapshots"libraryDependencies ++= Seq( "com.codahale" % "simplespec_2.9.0-1" % "0.4.1","co
我试图从sbt使用 scala -akka.

我的sbt文件如下所示:

name := "hello"

version := "1.0"

scalaVersion := "2.9.1"

resolvers += "akka" at "http://repo.akka.io/snapshots"

libraryDependencies ++= Seq(
  "com.codahale"      % "simplespec_2.9.0-1" % "0.4.1","com.typesafe.akka" % "akka-stm"           % "2.0-SNAPSHOT" 
)

我的代码:

import akka._

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello,world!")
  }
}

当我编译时,我得到了

]# **sbt compile**
[info] Set current project to default-91c48b (in build file:/var/storage1/home/test_user/dev_scala/hello/)
[info] Compiling 1 Scala source to /var/storage1/home/test_user/dev_scala/hello/target/scala-2.9.2/classes...
[error] /var/storage1/home/test_user/dev_scala/hello/src/main/scala/hw.scala:3: not found: object akka
[error] import akka._
[error]        ^
[error] one error found
[error] (compile:compile) Compilation failed
[error] Total time: 3 s,completed May 22,2013 8:59:08 PM

请指教.

EDIT2:
基于以下评论.这是新的sbt文件

name := "hello"
version := "1.0"
scalaVersion := "2.9.1"

resolvers += "akka" at "http://repo.akka.io/snapshots"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.1.4","com.codahale" % "simplespec_2.9.0-1" % "0.4.1","com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT","com.typesafe.akka" %% "akka-actor"    % "2.2-M3","com.typesafe.akka" %% "akka-slf4j"    % "2.2-M3","com.typesafe.akka" %% "akka-remote"   % "2.2-M3","com.typesafe.akka" %% "akka-testkit"  % "2.2-M3"% "test"
)

有任何想法吗 ?

解决方法

您没有项目的所有依赖项.

你添加了这个“com.typesafe.akka”%%“akka-actor”%“2.0.5”.这是与akka核心模块的主要依赖关系.此外,最好为您的akka??项目添加以下内容:

"com.typesafe.akka" %% "akka-actor"    % "2.0.5","com.typesafe.akka" %% "akka-slf4j"    % "2.0.5","com.typesafe.akka" %% "akka-remote"   % "2.0.5","com.typesafe.akka" %% "akka-agent"    % "2.0.5","com.typesafe.akka" %% "akka-testkit"  % "2.0.5"% "test"

要使用actor,你应该导入akka.actor._

更新

好的,这个构建文件适合我

name := "hello"

version := "1.0"

scalaVersion := "2.10.1"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor"   % "2.2-M3","com.typesafe.akka" %% "akka-slf4j"   % "2.2-M3","com.typesafe.akka" %% "akka-remote"  % "2.2-M3","com.typesafe.akka" %% "akka-agent"   % "2.2-M3","com.typesafe.akka" %% "akka-testkit" % "2.2-M3" % "test"
)

不要忘记在sbt中重新加载和更新项目

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读