*Scala [#qe7175fd] **Install [#i90433b5] *** Mac OS X & Homebrew [#l8dadf40] play frameworkは以下のコマンド一発で入る。便利。 $ brew install typesafe-activator -参考 --https://www.playframework.com/documentation/2.3.x/Migration23 --http://tototoshi.hatenablog.com/entry/2014/05/31/153143 *** Linux (Ubuntu 14.04 LTS) [#r2087c36] WIP ** create new project [#ta089099] $ activator new (projectname) `Fetching the latest list of templates... Browse the list of templates: http://typesafe.com/activator/templates Choose from these featured templates or enter a template name: 1) minimal-akka-java-seed 2) minimal-akka-scala-seed 3) minimal-java 4) minimal-scala 5) play-java 6) play-scala (hit tab to see a list of all templates) > 6 OK, application "(projectname)" is being created using the "play-scala" template. (projectname)のところで指定したディレクトリが作成されるのでcdする。そしておもむろに立ち上げてみる。 $ activator run http://localhost:9000/ にアクセスするとおもむろにコンパイルがはじまり、終わると「Welcome to play」のサンプルページが現れる。activator runは立ち上げたまま次のステップへ進んで良い(ファイルが更新されたら自動で再コンパイルが走る) ** Hello World [#wc0b423a] http://qiita.com/kukita/items/6326f1439abec013a479 ここの手順 1-9(Applicaton.scala編集)を行い、ブラウザをリロードすると再コンパイルが始まって"Hello, World."という文字列が表示される。 ** DBとの接続 [#k5af9aec] とりあえずbuild.sbtをいじる。 -Scala - PlayフレームワークでMYSQLの設定を行う - Qiita --http://qiita.com/dahugani/items/bb0bbd8fb263bc19cc57 ※ケツカンマに気をつけろ!!!!! **参考資料 [#qc6a9b60] *** PlayFramework - (60分クッキング) Play Framework (Scala)+MySQLでREST APIサーバーを作る - Qiita [#tde7eccd] -http://qiita.com/AKB428/items/bbb085a06c37bd84d0be *** Play 2.4 Hands on [#k61b2cc7] 導入部分はわかりやすかった -https://github.com/bizreach/play2-hands-on/tree/master/play2.4-slick3.0/markdown 感想 -"activator new play2-hands-on" が完了した時点で.gitignoreが自動的に作成されているので、この時点GitHubのでリポジトリ作成しちゃってよさそう。 -build.sbtを編集するときはケツカンマに注意だ!間違えるとこうなるぞ! [error] [/Users/karia/source/karia/scala-play-sample/build.sbt]:16: ')' expected but string literal found. Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q -初回のactivator runは数十分単位で時間かかる(猛然とダウンロード祭りが始まる) -HTTPのリクエストが来てからScalaのcompileをはじめる、ヤバい [info] Compiling 7 Scala sources and 1 Java source to /Users/karia/source/karia/scala-play-sample/target/scala-2.11/classes... [info] 'compiler-interface' not yet compiled for Scala 2.11.6. Compiling... [info] Compilation completed in 14.1 s Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js. [info] - play.api.Play - Application started (Dev) -2015/11/27時点でのバージョン Play 2.4.4 scala 2.11.6 |