Scala Play能够理解新的项目依赖性吗?

时间:2015-09-07 12:56:08

标签: scala playframework sbt typesafe-activator

我下载了最新的activator并按照其中的说明进行安装并创建了一个新的简单Play项目。新项目已成功创建,但是,我无法理解那里的依赖关系。

我看到生成的文件build.sbt不依赖于Play:

name := """play-template-new"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

相反,我看到在build/plugins.sbt下引用的sbt Play插件:"

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
// Play enhancer, regardless of whether the line above is commented out or not.
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

为什么使用sbt插件而不是正确的依赖?如何添加新的依赖项,例如光滑的最新版本?

1 个答案:

答案 0 :(得分:1)

play sbt-plugin将库依赖项添加到play框架中。只需使用插件,就可以获取所有必需的依赖项。您可以查看它在sbt-plugin的source-code中的完成情况。

至于添加slick依赖项,只需按照getting started中所述的正常sbt方式将以下内容添加到build.sbt文件中。

libraryDependencies ++= Seq(
  "com.typesafe.slick" %% "slick" % "2.1.0",
  "org.slf4j" % "slf4j-nop" % "1.6.4"
)