我已按照此documentation使用sbt创建一个新的Play应用程序myFirstApp。我在myFirstApp文件夹中有build.sbt
,在plugins.sbt
文件夹中有myFirstApp/project
。
但是,我从myFirstApp执行sbt
时收到以下错误,
~/ScalaWorkspace/myFirstApp/build.sbt:7: error: not found: value playScalaSettings
playScalaSettings
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
如何解决这个问题?
更新1:获取此错误:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#routes-compiler_2.9.2;2.1.1: not found
[warn] :: play#templates-compiler_2.9.2;2.1.1: not found
[warn] :: play#console_2.9.2;2.1.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-link;2.1.1!sbt-link.jar
[warn] :: play#play-exceptions;2.1.1!play-exceptions.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: play#routes-compiler_2.9.2;2.1.1: not found
unresolved dependency: play#templates-compiler_2.9.2;2.1.1: not found
unresolved dependency: play#console_2.9.2;2.1.1: not found
download failed: play#sbt-link;2.1.1!sbt-link.jar
download failed: play#play-exceptions;2.1.1!play-exceptions.jar
答案 0 :(得分:3)
这是我第一次以sbt
为中心的Play开发,如果解决方案不符合可接受的质量标准,请耐心等待。
我按照文档Creating a new application中的创建新应用程序而没有安装Play 这一部分,最后得到了以下文件。
build.sbt
如文档中所述。
import play.Project._
name := "My first application"
version := "1.0"
playScalaSettings
然后我创建了project/build.properties
,因为这是一种可重复构建的推荐方法 - sbt的版本已知且已修复。
sbt.version=0.13.0
我将project/plugins.sbt
修改为如下:
// Typesafe snapshots
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0-RC2")
使用项目中的文件,我可以执行sbt
并获得项目提示。
jacek:~/sandbox/myFirstApp
$ sbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/myFirstApp/project
[info] Set current project to My first application (in build file:/Users/jacek/sandbox/myFirstApp/)
[My first application] $ run
...lots of [SUCCESSFUL ]'s
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)