【发布时间】:2021-10-26 09:14:46
【问题描述】:
编写scala测试,遇到错误:
Symbol 'type org.scalatest.compatible.Assertion' is missing from the classpath.
This symbol is required by 'type org.scalatest.Assertion'.
Make sure that type Assertion is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'package.class' was compiled against an incompatible version of org.scalatest.compatible.
我的 build.sbt 很简单:
import sbt.Keys.libraryDependencies
ThisBuild / scalaVersion := "2.13.2"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"
ThisBuild / organizationName := "example"
lazy val root = (project in file("."))
.settings(
name := "myproj",
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.9",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.9" % "test",
libraryDependencies += "org.scalatest" %% "scalatest-funsuite" % "3.2.9" % "test",
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2",
)
仅当我在 IntelliJ 中构建项目时才会出现此问题。使用 sbt 本身可以很好地编译。
sbt version in this project: 1.3.10
sbt script version: 1.3.6
知道如何在 IntelliJ 中修复它吗?
【问题讨论】:
-
明显的建议但值得一提 - 你试过
File -> Invalidate Caches吗?
标签: scala intellij-idea sbt