通过 sbt 安装

如果你已经安装了 sbt,我发现在没有 activator 的情况下创建一个最小的 Play 项目会更容易。这是如何做。

# create a new folder
mkdir myNewProject
# launch sbt
sbt

完成上一步后,编辑 build.sbt 并添加以下行

name := """myProjectName"""

version := "1.0-SNAPSHOT"

offline := true

lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.6"
# add required dependencies here .. below a list of dependencies I use
libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  filters,
  specs2 % Test,
  "com.github.nscala-time" %% "nscala-time" % "2.0.0",
  "javax.ws.rs" % "jsr311-api" % "1.0",
  "commons-io" % "commons-io" % "2.3",
  "org.asynchttpclient" % "async-http-client" % "2.0.4",
  cache
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/"

最后,创建一个文件夹 project 并在里面创建一个文件 build.properties,并引用你想要使用的 Play 版本

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

而已! 你的项目准备好了。你可以使用 sbt 启动它。从 sbt 开始,你可以访问与 activator 相同的命令。