LoginSignup
3
4

More than 5 years have passed since last update.

Play Framework 2.3.7 コトハジメ

Posted at

ファイル配置とパス

/usr/local/bin/に下記の3つを配置。

  • activator
  • activator-launch-1.2.12.jar
  • activator.bat

Zshを使用しているため、.zshenvにパスを通した。

.zshenv
#Play Framework
export PATH=$PATH:/usr/local/bin/activator

試しにコマンドを叩いてみる

activator helpを叩くと、いきなりTypesafe社のURLからダウンロードが始まるが無視して問題ない。 無事ダウンロードが終わると、ヘルプページに飛ぶ。

新しいアプリケーションの作成

新規作成
$ activator new

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)
> play-java
Enter a name for your application (just press enter for 'play-java')
> test
OK, application "test" is being created using the "play-java" template.

To run "test" from the command line, "cd test" then:
/Users/nikuyoshi/workspace/meshitero/test/activator run

To run the test for "test" from the command line, "cd test" then:
/Users/nikuyoshi/workspace/meshitero/test/activator test

To run the Activator UI for "test" from the command line, "cd test" then:
/Users/nikuyoshi/workspace/meshitero/test/activator ui
新規作成後
$ activator run
Getting org.scala-sbt sbt 0.13.5 ...
---長いダウンロード後---
[info] Done updating.

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

[info] play - 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...)

http://localhost:9000/ にアクセスしてみると、無事以下のようなページが表示される。
スクリーンショット 2015-02-08 4.25.51.png

activator ui を実行すると、今度は画面上でソースコードを読める画面が出てきた。 テストなどもこの画面でできるらしい。 素晴らしい。
スクリーンショット 2015-02-08 4.40.16.png

新しいアプリケーションをEclipseで編集したい

変換したいプロジェクトのフォルダ直下でactivator eclipseを実行すれば良い。

$ activator eclipse
[info] Loading project definition from /Users/nikuyoshi/workspace/test/project
[info] Updating {file:/Users/nikuyoshi/workspace/test/project/}test-build...
Waiting for lock on /Users/nikuyoshi/.ivy2/.sbt.ivy.lock to be available...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to test (in build file:/Users/nikuyoshi/workspace/test/)
[info] About to create Eclipse project files for your project(s).
[info] Updating {file:/Users/nikuyoshi/workspace/test/}root...
Waiting for lock on /Users/nikuyoshi/.ivy2/.sbt.ivy.lock to be available...
[info] Resolving com.typesafe.trace#trace-sigar-libs;0.1.7 ...
[info] Done updating.
[info] Updating {file:/Users/nikuyoshi/workspace/test/}root...
Waiting for lock on /Users/nikuyoshi/.ivy2/.sbt.ivy.lock to be available...
[info] Resolving com.typesafe.trace#trace-sigar-libs;0.1.7 ...
[info] Done updating.
[info] Updating {file:/Users/nikuyoshi/workspace/test/}root...
Waiting for lock on /Users/nikuyoshi/.ivy2/.sbt.ivy.lock to be available...
[info] Resolving com.typesafe.trace#trace-sigar-libs;0.1.7 ...
[info] Done updating.
[info] Successfully created Eclipse project files for project(s):
[info] test

あとは、Eclipseからインポートをしてあげれば無事終了。 超簡単でちびった。
スクリーンショット 2015-02-08 4.47.25.png

インポート後にいきなりエラーが出ていたので、プロジェクトのプロパティからJava Compilerの設定を変更してJDK 1.7に変更したら無事エラーは解消された。 デフォルトだとJDKが1.4とかにされちゃうのかな?

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4