编译错误scala项目

时间:2017-12-22 16:21:46

标签: scala compiler-errors sbt

我参加了斯卡拉课程。我下载了示例项目,但我无法编译它。运行控制台命令时给我错误。

build.sbt:

name := course.value + "-" + assignment.value

scalaVersion := "2.12.4"

scalacOptions ++= Seq("-deprecation")

// grading libraries
libraryDependencies += "junit" % "junit" % "4.10" % Test

// for funsets
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"

resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases"

// include the common dir
commonSourcePackages += "common"

courseId := "bRPXgjY9EeW6RApRXdjJPw"

错误:

> console
[info] Updating root
[info] Resolved root dependencies
[trace] Stack trace suppressed: run last *:coursierResolution for the full output.
[error] (*:coursierResolution) coursier.ResolutionException: Encountered 1 error(s) in dependency resolution:
[error]   org.scalatest:scalatest_2.12:2.2.4:
[error]     not found:
[error]       /Users/joaonobre/.ivy2/local/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[error]       /Users/joaonobre/.sbt/preloaded/org.scalatest/scalatest_2.12/2.2.4/ivys/ivy.xml
[error]       /Users/joaonobre/.sbt/preloaded/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error]       https://repo1.maven.org/maven2/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error]       http://repo.artima.com/releases/org/scalatest/scalatest_2.12/2.2.4/scalatest_2.12-2.2.4.pom
[error] Total time: 1 s, completed Dec 22, 2017 4:16:17 PM

scala -version
Scala code runner version 2.12.4 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.

知道怎么解决吗?

感谢。

1 个答案:

答案 0 :(得分:0)

根据@laughedelic的建议,Scala 2.12没有scalatest-2.2.4。结果,sbt无法找到相关的scalatest pom文件。您可以选择here提及的任何版本。

例如,尝试在CommonBuild.scala文件中将scalaTestDependency版本更改为3.0.5

lazy val scalaTestDependency = "org.scalatest" %% "scalatest" % "3.0.5"

这是课程link(第1周的实践编程作业)