IDEA中的scalatest编译出错

问题描述:

我正在尝试编译包含scalatest的Scala项目。
它在sbt上编译正常

I am trying to compile Scala project which contains scalatest. It compiles normal on sbt

sbt
> compile
> test:compile

,但是当我尝试使用IDEA构建它时,它显示以下错误:

, but when I am trying to build it with IDEA, it shows the following error:

Error:(37, 11) exception during macro expansion: 
java.lang.NoSuchMethodError: org.scalactic.BooleanMacro.genMacro(Lscala/reflect/api/Exprs$Expr;Ljava/lang/String;Lscala/reflect/api/Exprs$Expr;)Lscala/reflect/api/Exprs$Expr;
at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:34)
assert((ElementMeasures.baseElementDistance(mEl1, mEl2) - 0.33333).abs < 0.001)
      ^

测试中每个断言函数的

for each assert function in test.

build.sbt 文件包含以下内容:

name := "ner-scala"
organization := "ml.generall"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.8"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
...


它也可能意味着你有多个版本的scalatest注册。我遇到了与assert

It may also mean that you have more than one versions of scalatest registered. I came into pretty same issue with compile-time error on assert