![](/img/trans.png)
[英]error while loading DefaultFormats, Scala signature DefaultFormats has wrong version
[英]ScalaTest I get error while loading Suite, Scala signature Suite has wrong version
我有一个依赖的 Maven 项目:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.5</version>
<scope>test</scope>
</dependency>
并有一个像这样的测试类套件:
import java.util.{LinkedHashMap => jLinkedHashMap, ArrayList => jArrayList, Arrays}
import org.scalatest._
class NeutralizeEITSuite extends FunSuite with Matchers {
val nEIT = new NeutralizeEIT()
test("Valid content category 'MiniSeries' is neutralized to 'TV Entertainment':") {
val result = neutralizedEIT(content_category = "MiniSeries")
val content_category = getStringValueFromEIT("content_category", result)
content_category should equal ("TV Entertainment")
}
}
我在编译过程中收到一个我不明白的错误:
[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java:-1: info: compiling
[INFO] Compiling 10 source files to C:\PROJECTS\active\Farallon\Hyperion\master\target\test-classes at 1454551605523
[ERROR] error: error while loading Suite, Scala signature Suite has wrong version
[INFO] expected: 5.0
[INFO] found: 4.1 in Suite.class
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:9: error: illegal inheritance;
[INFO] self-type com.mycompany.ese.ingest.neutralizeEITSuite does not conform to org.scalatest.FunSuite's selftype org.scalatest.FunSuite
[INFO] class neutralizeEITSuite extends FunSuite with Matchers {
[INFO] ^
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:9: error: illegal inheritance;
[INFO] self-type com.mycompany.ese.ingest.neutralizeEITSuite does not conform to org.scalatest.Matchers's selftype org.scalatest.Matchers
[INFO] class neutralizeEITSuite extends FunSuite with Matchers {
[INFO] ^
[ERROR] C:\PROJECTS\active\Farallon\Hyperion\master\src\test\java\com\mycompany\ese\ingest\NeutralizeEITSuite.scala:15: error: recursive value result needs type
[INFO] val content_category = getStringValueFromEIT("content_category", result)
我试过谷歌搜索错误,但没有结果。 我的 pom.xml 中没有额外的 org.scalatest 依赖项
FunSuite 的 4.1 和 5.0 版本在哪里?
谢谢,
content_category
变量与之前的content_category
命名参数可能存在冲突。
通过更新我的 pom 中的 scala 规范依赖项解决了问题
从
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.6.2.2_1.5.0</version>
<scope>test</scope>
</dependency>
到
<dependency>
<groupId>org.scala-tools.testing</groupId>
<artifactId>specs</artifactId>
<version>1.6.2.2_1.5.0</version>
</dependency>
我在 5 年后来到这里,所以对于通过 Google 到达这里的任何人......这些天的答案是你的 pom.xml 中可能有一个旧版本的 org.specs(可能是因为你从旧版本中复制并粘贴了源),以及新的 org.scalatest 库。
如果两者都有,解决方法是删除它:
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>[Some version]</version>
<scope>test</scope>
</dependency>
只留下这个:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.2.9</version>
<scope>test</scope>
</dependency>
(其中 _2.11 替换为您正在使用的 Scala 版本,而 3.2.9 替换为您正在使用的 ScalaTest 版本。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.