modal_soulの記録

バイクおじさんの日常とメンテナンス、そしてその記録

バイクおじさんの日常とメンテナンス

Play! framework 2.0 betaを使ってみる

タイミングを芯で捉えられていない感はありますが、  Play! framework 2.0 betaを使ってみます。

とりあえずインストール。  https://github.com/playframework/play20

前回”git”を導入したわけですが、Zipファイルをダウンロード中に  「あ、git使おう」と思い立ったので、普通にzipを解凍して配置&パスを通してインストールは完了です。 こんなあんばい

20111205225907

アプリケーションを作ってみる

>|| \workspace> play new helloWorld Windows, really? Ok, disabling colors. _ _ _ __ | | __ _ _ _| | | '_ \| |/ _' | || |_| | __/|_|\____|\__ (_) |_| |__/ play! 2.0-beta, http://www.playframework.org The new application will be created in \workspace\helloWorld What is the application name? > helloWorld ||<

もちろんScalaを選択。

>|| 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 > 1 OK, application helloWorld is created. Have fun! ||<

最後の「Have fun!」てのがいいですよねw

で、これを実行して「localhost:9000」にアクセスすると、こんな感じ

20111205234019

動いてます。

ローカルだけだとあれなんで、雲の上に乗せてみよう  ということで、勉強会に行くとなにかとうわさのHerokuを使ってみる

さっそくチュートリアルを読む http://devcenter.heroku.com/articles/scala

Herokuコマンドラインクライアントツールをインストール  コマンドラインからログインし、sshの公開鍵を作成

>> $ heroku login Enter your Heroku credentials. Email: Password: Could not find an existing public key. Would you like to generate one? [Yn] y Generating new SSH public key. Uploading ssh public key /Users/adam/.ssh/id_rsa.pub <<

アプリケーションのルートディレクトリに、build.sbtを作成

>|| import com.typesafe.startscript.StartScriptPlugin seq(StartScriptPlugin.startScriptForClassesSettings: _*) name := "hello" version := "1.0" scalaVersion := "2.8.1" resolvers += "twitter-repo" at "http://maven.twttr.com" libraryDependencies ++= Seq("com.twitter" % "finagle-core" % "1.9.0", "com.twitter" % "finagle-http" % "1.9.0") ||<

スタートスクリプトプラグイン追加のために、project/build.sbtを作成

>|| resolvers += Classpaths.typesafeResolver addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.3.0") ||<

さて、実際に動かすところまでやりたかったんですが、眠いので今回はここまで  次回につづく、、