【问题标题】:'type scala.collection.generic.GenericTraversableTemplate' is missing from the classpath类路径中缺少“type scala.collection.generic.GenericTraversableTemplate”
【发布时间】:2019-07-07 15:00:02
【问题描述】:

我试图在 Scala 2.13.0 中使用两个 ParRanges(并行范围)来执行任意操作,但我似乎缺少一些依赖项并且不确定它是什么。

我正在 IntelliJ IDEA Ultimate 2019.1.3 中开发游戏,使用 Libgdx 框架 v1.9.9,在 Scala 2.13.0 中使用 Gradle 进行依赖管理

我的全局库中有 Scala 2.13.0 SDK,并且我已将这些依赖项(以及其他)导入到我的 build.gradle 项目中:

<... rest of build.gradle file above>

project(":desktop") {
    apply plugin: "java"
    apply plugin: "scala"

    dependencies {
        compile "org.scala-lang:scala-library:2.13.0"
        <other dependencies>
    }
}

project(":core") {
    apply plugin: "java"
    apply plugin: "scala"

    dependencies {
        compile "org.scala-lang:scala-library:2.13.0"
        compile "org.scala-lang.modules:scala-parallel-collections_2.13.0-M2:1.0.2"
        <other dependencies>
    }
}

<... rest of build.gradle file below>

有问题的示例代码是:

    ParRange(0, Width, 1, true).foreach(x => {
      ParRange(0, Height, 1, true).foreach(y => {
        pixmap.setColor(Math.random().toFloat, Math.random().toFloat, Math.random().toFloat, 1)
        pixmap.drawPixel(x, y)
      })
    })

当我尝试运行该程序时,我同样遇到了几个运行时错误:

Error:(29, 27) Symbol 'type scala.collection.generic.GenericTraversableTemplate' is missing from the classpath.
This symbol is required by 'trait scala.collection.generic.GenericParTemplate'.
Make sure that type GenericTraversableTemplate is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'GenericParTemplate.class' was compiled against an incompatible version of scala.collection.generic.
    ParRange(0, Width, 1, true).foreach(x => {

还缺少:

'type scala.collection.GenIterableLike'
'type scala.collection.Parallel'
'type scala.collection.GenSeqLike'
'type scala.Immutable'

为了使用并行集合,我花了很多时间弄清楚我应该在 build.gradle 中导入什么依赖项。

根据 2.12.1 的 ScalaDocs,这些都应该存在:参见 https://www.scala-lang.org/api/2.12.1/scala/collection/generic/GenericTraversableTemplate.html

但是,2.13.0 的 ScalaDocs 显示这些都缺失:请参阅 https://www.scala-lang.org/api/2.13.0/scala/collection/generic/index.html

为什么 Scala 2.13.0 的并行集合依赖于 Scala 2.12.1 中存在的类和特征,而不是 Scala 2.13.0 中的类和特征?

【问题讨论】:

标签: scala gradle libgdx


【解决方案1】:

为什么 Scala 2.13.0 的并行集合依赖于 Scala 2.12.1 中存在的类和特征,而不是 Scala 2.13.0 中的类和特征?

因为它不是 2.13 的版本,它适用于 2.13.0-M2(仍然有它们)。 https://mvnrepository.com/artifact/org.scala-lang.modules/scala-parallel-collections 表明这个版本是 2017 年的,而 0.2.0 是为 2.13 发布的实际最新版本,尽管有版本号。

【讨论】:

    猜你喜欢
    • 2021-12-09
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多