簡體   English   中英

我從頭開始在IntelliJ的第一個Akka項目。 編譯依賴性錯誤。

[英]My First Akka project in IntelliJ from scratch. Compile dependency error.

我時不時地從頭開始,以確保我知道設置項目的所有復雜細節是什么。 我有一個簡單的應用程序,如下所示,但我得到一些依賴性問題似乎並沒有指向我任何地方。 我正在使用scala版本2.11。

我的SBT:

name := "Helios"

version := "1.0"

scalaVersion := "2.11.8"

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

libraryDependencies ++= Seq(
  "com.typesafe.akka" % "akka-actor" % "2.0.2",
  "com.typesafe.akka" % "akka-slf4j" % "2.0.5")

我的樣本班

import com.echostar.ese.helios.core.Asset
import akka.actor._

class NSPSG extends Actor {

  def receive = {
    case a: Asset => {
      println(s"NSPSG Received asset: ${a}")
    }
    case _ => println("Unexpected message received")
  }
}

(資產類只是一個包含id和title的案例類。)

錯誤消息

C:\PROJECTS\active\Helios>sbt compile
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading global plugins from C:\Users\dana.murad\.sbt\0.13\plugins
[info] Loading project definition from C:\PROJECTS\active\Helios\project
[info] Set current project to Helios (in build file:/C:/PROJECTS/active/Helios/)
[info] Updating {file:/C:/PROJECTS/active/Helios/}helios...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 3 Scala sources to C:\PROJECTS\active\Helios\target\scala-2.11\classes...
[error] missing or invalid dependency detected while loading class file 'package.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'package.class' was compiled against an incompatible version of scala.
[error] missing or invalid dependency detected while loading class file 'Actor.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Actor.class' was compiled against an incompatible version of scala.
[error] C:\PROJECTS\active\Helios\src\main\scala\com\echostar\ese\helios\workers\NSPSG.scala:9: illegal inheritance;
[error]  self-type com.echostar.ese.helios.workers.NSPSG does not conform to akka.actor.Actor's selftype akka.actor.Actor
[error] class NSPSG extends Actor {
[error]                     ^
[error] three errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Apr 4, 2016 9:19:45 AM

我的主要應用程序現在只是一個println。 它甚至不叫這個演員。

我使用scala 2.11的錯誤版本的akka​​嗎? -Ylog-classpath沒有幫助

不知道是什么修復它,但這里是我做的事情列表,現在項目編譯。

  1. 將akka依賴項更改為此(添加了兩倍,並將版本更改回2.4)

     libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.4.0" ) 
  2. 刪除了我的運行配置並再次添加回來。 (我認為main的路徑顯示為紅色(無效),因此重做它有助於解決它。我更改了我的包名稱,我不認為intelliJ在build-conf中獲得了重命名)

  3. 從IntelliJ菜單(Scala中的Akka Main)啟動了另一個測試項目,並花了一些時間來下載所有依賴項。 那么也許我的項目需要那些而不是下載它們?

  4. 刪除注釋掉的行(擺脫了分號)。 我不認為除了完全披露之外沒有做任何事情,技術上我確實觸摸了代碼,即使我的演員定義完全相同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM