Play Frameworkに対して勉強した内容の整理。
Scalaの一番有名なフレームワークはPlay Frameworkである。
Play Frameworkに対して簡単に勉強しようと。
特に話がない内容はPlayFramework公式ホームページの内容を基に作成。
Installing Play
事前に必要なこと
JDK
PlayにはJava1.8以上のバージョンが必要である。
OracleのJDKサイトにてダウンロード&インストール。
SBT
SBTダウンロードページにてダウンロード&インストール
Creating a new Application
$ sbt new playframework/play-scala-seed.g8
$ cd play-scala-seed
$ sbt run
http://localhost:9000にて確認可能
Using the Play Console
コードの実行
$ cd play-scala-seed
$ sbt
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Programming\WORKS\SCALA\play-scala-seed\project
[info] Set current project to play-scala-seed (in build file:/C:/Programming/WORKS/SCALA/play-scala-seed/)
[play-scala-seed]$
Developモードでサーバを実行
[play-scala-seed]$ run
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
コンパイル
[play-scala-seed]$ compile
[success] Total time: 0 s, completed 2017/04/25 17:21:00
Test実行
[play-scala-seed]$ test
[info] Compiling 1 Scala source to C:\Programming\WORKS\SCALA\play-scala-seed\target\scala-2.11\test-classes...
[info] HomeControllerSpec:
[info] HomeController GET
[info] - should render the index page from a new instance of controller
[info] - should render the index page from the application
[info] - should render the index page from the router
[info] ScalaTest
[info] Run completed in 2 seconds, 901 milliseconds.
[info] Total number of tests run: 3
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 3, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 3, Failed 0, Errors 0, Passed 3
[success] Total time: 8 s, completed 2017/04/25 17:21:30