我正在尝试在我的OSX计算机上运行一些Scala代码并继续收到错误消息
error: object specs2 is not a member of package org
我安装了Scala版本2.9.1-1。 我也使用版本0.7.7的sbt
我的build.sbt文件看起来像这样
name := "Comp-338-Web-App"
version := "1.0"
scalaVersion := "2.9.1"
scalacOptions += "-deprecation"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.7",
"org.specs2" %% "specs2" % "1.8.2" % "test",
"org.mockito" % "mockito-all" % "1.9.0",
"org.hamcrest" % "hamcrest-all" % "1.1"
)
resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases")
我尝试了很多不同的东西,却无法让它正确运行测试。
有什么建议吗?
如果您需要有关计算机设置的更多信息,请与我们联系。
答案 0 :(得分:3)
解决方案看起来很简单:请使用最新版本的sbt,目前为0.11.2。
您使用的0.7.x版本不知道如何使用 build.sbt ,这只是在sbt 0.9中引入的。
答案 1 :(得分:0)
除了转到sbt 0.11.2之外,我建议转到full configuration,即使作者建议对大多数任务使用.sbt描述符,并且只有在无法使用.sbt实现某些内容时才使用.scala描述符。语法或使用子项目(我的所有项目都是为了清楚地分隔应用程序的不同部分)。
以下是我刚刚开始使用的项目的示例项目设置,因此它只有specs2依赖项:
import sbt._
import Keys._
object BuildSettings {
val buildOrganization = "net.batyuk"
val buildScalaVersion = "2.9.1"
val buildVersion = "0.1"
val buildSettings = Defaults.defaultSettings ++ Seq(organization := buildOrganization,
scalaVersion := buildScalaVersion,
version := buildVersion)
}
object Resolvers {
val typesafeRepo = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
val sonatypeRepo = "Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases"
val scalaResolvers = Seq(typesafeRepo, sonatypeRepo)
}
object Dependencies {
val specs2Version = "1.8.2"
val specs2 = "org.specs2" %% "specs2" % specs2Version
}
object IdefixBuild extends Build {
import Resolvers._
import Dependencies._
import BuildSettings._
val commonDeps = Seq(specs2)
lazy val idefix = Project("idefix", file("."), settings = buildSettings ++ Seq(resolvers := scalaResolvers,
libraryDependencies := commonDeps))
}