java Play框架入门 ( simple tutorial for play framework)
访问量: 4190
注意::: 官方的文档不给力啊,按照他说的做,会遇到各种问题。文档更新的速度没跟上代码。。。最好的办法是运行: sample 目录下的 项目。 ( CAUTION: official tutorial is not correct from my experience today, the best way is to run the sample applications in the "sample" folder , check it out! )
1. 下载并解压缩最新的文件。( Download and unzip the play framework file ) :
2. 为 "play" 这个文件加上可执行的标志 : chmod +x play ,并把它放到系统PATH中。 ( make the 'play' file executable and add its path to PATH )
3. 建立一个空的应用 : ( create an empty play application)
$ play new test_play_framework
4. 打开控制台: (open its console)
$ cd test_play_framework
$ run
sg552@siwei-moto:~/workspace/test_play$ play [info] Loading project definition from /home/sg552/workspace/test_play/project [info] Set current project to test_play (in build file:/home/sg552/workspace/test_play/) _ _ _ __ | | __ _ _ _| | | '_ \| |/ _' | || |_| | __/|_|\____|\__ (_) |_| |__/ play! 2.0.3, http://www.playframework.org > Type "help play" or "license" for more information. > Type "exit" or use Ctrl+D to leave this console. [test_play] $ run [info] Updating {file:/home/sg552/workspace/test_play/}test_play... [info] Done updating. --- (Running the application from SBT, auto-reloading is enabled) --- [info] play - Listening for HTTP on port 9000... (Server started, use Ctrl+D to stop and go back to the console...)
可以看到服务器运行在了9000端口,打开。。。( we could see that the server is running at: localhost:9000, open it )