即使你使用IntelliJ IDEA或是Eclipse IDE来开发Play应用,了解Play Console的使用还是非常有用的,Play Console 为一基于sbt的命令行工具,可以用来管理Play应用的开发生命周期。
启动Play Console
使用Play Console前,注意把Play所在目录添加到系统目录中,这样,启动Play Console 非常简单,只需在Play应用所在目录在命令行输入 “play”
play

获得Play 命令帮助
你可以输入help play 获得关于Play命令使用的基本方法和命令:
常见的命令如下:
play Enter the play console
help Displays this help message or prints detailed help on requested commands (run 'help <command').
about Displays basic information about sbt and the build.
tasks Lists the tasks defined for the current project.
settings Lists the settings defined for the current project.
reload (Re)loads the project in the current directory
projects Lists the names of available projects or temporarily adds/removes extra builds to the sessio.
project Displays the current project or changes to the provided `project`.
set Evaluates a Setting and applies it to the current project.
session Manipulates session settings. For details, run 'help session'.
inspect Prints the value for 'key', the defining scope, delegates, related definitions, and dependenies.
; <command> (; <command>)* Runs the provided semicolon-separated commands.
~ <command> Executes the specified command whenever source files change.
last Displays output from a previous command or the output from a specific task.
last-grep Shows lines from the last output for 'key' that match 'pattern'.
exit Terminates the build.
show <key> Displays the result of evaluating the setting or task associated with 'key'.
在开发模式下启动Play应用
使用run 命令,可以开发模式下启动Play应用,此时一些调整信息可以在屏幕上显示出来,缺省情况下,Play Web应用使用端口9000,如果你修改代码,Play Console会检测到代码变化,在下个请求时会自动重新编译代码或资源,如要必要,还可以重新启动Play应用。如果出现编译错误,那么在浏览器中会显示错误信息:

如果要停止Web服务,可以按Ctrl+D ,此外还可以通过任务管理器,杀死对应的Java进程来停止Web服务。
编译
Compile 命令可以编译Play 源码或是资源(如CoffeeScript代码,LESS代码,Scala代码等),如果出现编译错误,屏幕上显示对应的错误提示:

调试命令
如果你使用Eclipse IDE,你可以使用Eclipse来调试代码,此时需要使用 play debug 启动一个JPDA调试端口,缺省调试端口为 9999,此后可以通过配置Eclipse远程调试指向这个端口,就可以使用Eclipse和其它Java 调试器来调试代码,如果使用IntelliJ IDEA IDE可以自动完成这些配置。
强制清理编译结果
如果你觉得编译的结果出现意想不到的机会,那么你的sbt的缓存可能出现问题,此时可以通过 clean-all 命令强制清除之前的编译结果,然后使用compile 重新编译生成新的编译内容。
此外play Console 基于 sbt 工具,因此你也可以使用sbt 的一些功能 ,比如 ~compile ,~run, ~test等