4

我正在尝试学习如何使用 SBT,而我发现的以下简单示例无法找到 scalatest 的版本:

name := "DoingItWrong"

version := "0.0.1"

scalaVersion := "2.10.1"

libraryDependencies ++= Seq (
  "org.scalatest" %% "scalatest" % "1.9.1" % "test"
)

在尝试 sbt 之前我使用的是 maven,并且以下依赖项可以正常工作:

<dependency>                                                            
   <groupId>org.scalatest</groupId>                                    
   <artifactId>scalatest_2.10</artifactId>                             
   <version>1.9.1</version>                                            
</dependency> 

我在尝试运行 SBT 时得到以下输出:

$ sbt package              
[info] Loading global plugins from /home/rafael/.sbt/plugins
[info] Set current project to DoingItWrong (in build file:/home/rafael/Dev/DoingItWrong/)
[info] Updating {file:/home/rafael/Dev/DoingItWrong/}default-c52ace...
[info] Resolving org.scala-lang#scala-library;2.10.1 ...
[info] Resolving org.scalatest#scalatest_2.10.1;1.9.1 ...
[warn]  module not found: org.scalatest#scalatest_2.10.1;1.9.1
[warn] ==== local: tried
[warn]   /home/rafael/.ivy2/local/org.scalatest/scalatest_2.10.1/1.9.1/ivys/ivy.xml
[warn] ==== Sonatype snapshots: tried
[warn]   http://oss.sonatype.org/content/repositories/snapshots/org/scalatest/scalatest_2.10.1/1.9.1/scalatest_2.10.1-1.9.1.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/scalatest/scalatest_2.10.1/1.9.1/scalatest_2.10.1-1.9.1.pom
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scalatest#scalatest_2.10.1;1.9.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/home/rafael/Dev/DoingItWrong/}default-c52ace/*:update: sbt.ResolveException: unresolved dependency: org.scalatest#scalatest_2.10.1;1.9.1: not found
[error] Total time: 1 s, completed Jun 6, 2013 9:45:49 AM

我缺少一些存储库还是什么?

我也试过scalaVersion := "2.10.0"2.10.0-M4。Scala 2.10 通过 SBT 的 scalatest 的最新可用版本是什么?

4

1 回答 1

8

为确保这不是潜在的 SBT 项目的配置问题,暂时不要使用该%%符号。事实上,这会自动选择与您当前的 scala 版本相对应的 Jar 版本,这可能与您期望的不同(您的 conf 中的疏忽,某些配置文件中的变量冲突等......)。

更喜欢这个以隔离您的“错误”上下文:

libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test"

我刚试过,效果很好。

于 2013-06-06T13:03:16.713 回答