Scala IDEでPlay frameworkを使う(プロジェクトを作る)

前回の続き。基本的にはこれに沿って進める。まずはScala IDEとPlay frameworkのプラグインがインストールできたのでプロジェクトを作る。

Playアプリケーションの起動

まずは作成したプロジェクト(test)に移動してplayコマンドを実行する。実行したらrunコマンドでアプリケーションが起動する。

$ cd test
$ play
 ...
[test] $ run

あとはhttp://localhost:9000/にアクセスすると以下のようなページが表示される。

f:id:mi_kami:20130617223328p:plain

それぞれのタイミングで何をやってるんだろう?最初にアクセスしたときに必要なファイルをコンパイルしてるように見える。

eclipseコマンドでPlayのeclipseプロジェクトを作る

Playのeclipseコマンドを使ってeclipseプロジェクトを作る。まずはctrl-dでrunモードから抜け、"eclipse"とタイプする。

[test] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] test

そしてもう1度アプリケーションを実行する。

[test] $ run

--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0%0:9000

(Server started, use Ctrl+D to stop and go back to the console...)


ここでeclipseに戻り、Preferenceを開く。フィルタに"workspace"とタイプし、Workspaceの設定を開いて、"Refresh using native hooks or polling"にチェックを入れる。

f:id:mi_kami:20130617224948p:plain


次に、Project ExplorerかPackage Explorerで右クリックして、Importを選択する。"Existing Projects into Workspace"を選択してNextをクリック。

f:id:mi_kami:20130617225215p:plain


"Select or root directory"でplayのプロジェクトフォルダを選択する。フォルダ配下を検索して見つかったtestのeclipseプロジェクトを選択して、Finishボタンをクリックする。

f:id:mi_kami:20130617225419p:plain


エラーが出ていなければインポートは完了。明日は実際に使うところを書く。