2013-01-23

Playframework : サンプルアプリケーション作成



◇ 環境


  • OS: MacOS X 10.8.2
  • Playframework: 2.0.4
  • Java: 1.7.0_11



◆ サンプルアプリケーション作成


[play new]コマンドを実行し、サンプルアプリケーションを作成する

  • 「/Users/username/」ディレクトリ配下に「testapp」と言うサンプルアプリケーションを作成する

$ cd /Users/username/

$ play new testapp
      _            _ 
 _ __ | | __ _ _  _| |
| '_ \| |/ _' | || |_|
|  __/|_|\____|\__ (_)
|_|            |__/ 
             
play! 2.0.4, http://www.playframework.org

The new application will be created in /Users/username/testapp

What is the application name? 
> testapp

Which template do you want to use for this new application? 

  1 - Create a simple Scala application
  2 - Create a simple Java application
  3 - Create an empty project

> 2

OK, application testapp is created.

Have fun!

ディレクトリ構造を確認する

$tree
.
└── testapp
    ├── README
    ├── app
    │   ├── controllers
    │   │   └── Application.java
    │   └── views
    │       ├── index.scala.html
    │       └── main.scala.html
    ├── conf
    │   ├── application.conf
    │   └── routes
    ├── project
    │   ├── Build.scala
    │   ├── build.properties
    │   └── plugins.sbt
    └── public
        ├── images
        │   └── favicon.png
        ├── javascripts
        │   └── jquery-1.7.1.min.js
        └── stylesheets
            └── main.css



◆ サンプルアプリケーションのテスト起動


[play run]コマンドを実行し、サンプルアプリケーションを実行する

$ cd /Users/username/testapp/

$ play

[info] Loading project definition from /Users/username/testapp/project
[info] Set current project to testapp (in build file:/Users/username/testapp/)
       _            _ 
 _ __ | | __ _ _  _| |
| '_ \| |/ _' | || |_|
|  __/|_|\____|\__ (_)
|_|            |__/ 
             
play! 2.0.4, http://www.playframework.org

> Type "help play" or "license" for more information.
> Type "exit" or use Ctrl+D to leave this console.

[testapp] $ run

[info] Updating {file:/username/testapp/}testapp...
[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...)
  • サーバ停止: [Ctr + D]コマンド
  • Play 終了: [Ctr + D]コマンド

「http://localhost:9000」へアクセスし、画面が表示されれば OK



◇ 参考





0 件のコメント:

コメントを投稿