这就是我们的项目结构
.
├── build.sbt
├── client
│ └── build.sbt
├── project
│ └── Build.scala
└── worker
└── build.sbt
项目/ Build.scala
object Dependencies {
val slf4jApi = slf4jGroup % slf4jModule("api") % slf4jVersion
val elasticSearch = "org.elasticsearch" % "elasticsearch" % "0.90.7"
}
工人/ build.sbt
import Dependencies._
distJvmOptions in Dist := "-Xms256M -Xmx1024M"
outputDirectory in Dist := baseDirectory.value / "target/dist"
libraryDependencies ++= Seq(
slf4jApi,
"org.elasticsearch" % "elasticsearch" % "0.90.7"
)
worker
项目中的依赖项未得到解决,我收到以下错误:
build.sbt:1:错误:未找到:对象依赖项 import Dependencies._ ^
我认为build.sbt
项目中的worker
无法查看Dependencies
中的Build.scala
对象,但我不确定如何克服此问题。有什么想法吗?
答案 0 :(得分:0)
以下配置对我来说运作正常,虽然我没有在您的问题中指出问题,但我在此处将其作为参考。
由于client
没有兴趣解决这一特定问题,因此请将其删除(尽管它已在build.sbt
下面定义 - 没有build.sbt
client
已定义。)
<强>项目/ Build.scala 强>
import sbt._
object Dependencies {
val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.5"
}
<强> build.sbt 强>
lazy val client, worker = project
<强>工人/ build.sbt 强>
import Dependencies._
libraryDependencies += slf4jApi
通过配置,sbt
显示:
[project-build]> sbtVersion
[info] worker/*:sbtVersion
[info] 0.13.1
[info] client/*:sbtVersion
[info] 0.13.1
[info] project-build/*:sbtVersion
[info] 0.13.1
[project-build]> projects
[info] In file:/Users/jacek/sandbox/so/project-build/
[info] client
[info] * project-build
[info] worker
[project-build]> show worker/libraryDependencies
[info] List(org.scala-lang:scala-library:2.10.3, org.slf4j:slf4j-api:1.7.5)
这可能是因为您使用旧版本的SBT(前 0.13 )吗?