我正尝试在我的OSX机器上运行一些Scala代码,并且一直收到如下错误
error: object specs2 is not a member of package org
我安装了版本2.9.1-1的Scala。我也在使用sbt的0.7.7版本
我的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")我尝试了很多不同的方法,但都不能让它正确地运行测试。
有什么建议吗?
如果您需要有关我电脑上的设置的更多信息,请告诉我。
发布于 2012-04-03 15:38:01
解决方案看起来很简单:请使用sbt的最新版本,目前为0.11.2。
您正在使用的0.7.x版本不知道如何使用build.sbt,这是在SBT0.9左右引入的。
发布于 2012-04-03 18:32:57
除了迁移到SBT0.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))
}https://stackoverflow.com/questions/9985483
复制相似问题