gpt4 book ai didi

scala - 类路径中缺少“类型scala.collection.generic.GenericTraversableTemplate”

转载 作者:行者123 更新时间:2023-12-03 05:06:39 25 4
gpt4 key购买 nike

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

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

我的全局库中有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中存在的类和特征?

最佳答案

Why would the parallel collections for Scala 2.13.0 rely upon classes and traits present in Scala 2.12.1 but not in 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发布的实际最新版本。

关于scala - 类路径中缺少“类型scala.collection.generic.GenericTraversableTemplate”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56923286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com