我从头开始在IntelliJ的第一个Akka项目。编译依赖性错误。

时间:2016-04-04 15:30:01

标签: scala compilation dependencies sbt akka

我时不时地从头开始,以确保我知道设置项目的所有复杂细节是什么。我有一个简单的应用程序,如下所示,但我得到一些依赖性问题似乎并没有指向我任何地方。我正在使用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 个答案:

答案 0 :(得分:0)

不知道修复了什么,但这里列出了我所做的事情以及项目现在编制的内容。

  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. 删除注释掉的行(摆脱了分号)。我不认为这做了什么,只是完全披露,技术上我确实触摸了代码,即使我的演员定义完全相同。