我的build.sbt文件中有各种库依赖项
scalaVersion := "2.10.5",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.5" % "test",
"org.apache.spark" %% "spark-core" % "1.6.1" % "provided",
"commons-logging" % "commons-logging" % "1.2"
) map (_.excludeAll(
ExclusionRule(organization = "org.slf4j"),
ExclusionRule(organization = "log4j"),
ExclusionRule(organization = "javax.servlet")
)),
libraryDependencies ++= Seq(("org.slf4j" % "slf4j-log4j12" % "1.7.10")
.excludeAll(ExclusionRule(organization = "log4j"))),
libraryDependencies += "log4j" % "log4j" % "1.2.16" % "test",
我可以在项目视图中的外部库中看到它们。
这是一个子模块。 并且依赖项在父级build.sbt中声明。代码在子项目中。
我试过了:
任何帮助表示感谢。
答案 0 :(得分:0)
还需要在子项目中明确添加依赖项。
例如,在项目根文件夹的build.sbt
中,您可以设置:
val commonDependencies = Seq(
"commons-io" % "commons-io" % "2.5"
// other dependencies
)
val root = (project in file(".")).settings(
libraryDependencies ++= commonDependencies,
libraryDependencies ++= Seq(
// dependencies only for project root
)
)
val topWordsCounter = (project in file("top-words-counter"))
.settings(
libraryDependencies ++= commonDependencies,
libraryDependencies ++= Seq(
// dependencies only for the sub project project top-words-counter
)
)
希望这有帮助