LoginSignup
1
1

More than 5 years have passed since last update.

Play Frameworkを使ってみる1

Posted at

play命令を実行してみる

play命令を実行してみます。

c:\work\play>play
Getting org.fusesource.jansi jansi 1.11 ...
:: retrieving :: org.scala-sbt#boot-jansi
        confs: [default]
        1 artifacts copied, 0 already retrieved (111kB/16ms)
Getting com.typesafe.play console_2.10 2.2.6 ...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        6 artifacts copied, 0 already retrieved (2012kB/282ms)
Getting Scala 2.10.3 (for console)...
:: retrieving :: org.scala-sbt#boot-scala
        confs: [default]
        5 artifacts copied, 0 already retrieved (24447kB/125ms)
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/

play 2.2.6 built with Scala 2.10.3 (running Java 1.8.0_51), http://www.playframework.com

This is not a play application!

Use `play new` to create a new Play application in the current directory,
or go to an existing application and launch the development console using `play`.

You can also browse the complete documentation at http://www.playframework.com.

初回起動の際には、幾つかの必要なファイルがダウンロードされます。

play命令はplayのバージョンと説明を表示するだけで終了します。

play new命令を実行してみる

新しいアプリケーションを作成するにはplay new命令を実行します。引数としてフォルダ名を指定します。play new命令を実行すると、最初に新しく作成するアプリケーションの名称を尋ねられるので、適当な名称を入力してEnterキーを押下します。次に新しいアプリケーションに対して何れの雛形を適用するか尋ねられるので、Scalaアプリケーションを選択します。

c:\work\play>play new hitotume
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/

play 2.2.6 built with Scala 2.10.3 (running Java 1.8.0_51), http://www.playframework.com

The new application will be created in C:\work\play\hitotume

What is the application name? [hitotume]
> namae

Which template do you want to use for this new application?

  1             - Create a simple Scala application
  2             - Create a simple Java application

> 1
OK, application namae is created.

Have fun!

現在のフォルダの下に指定した名称のフォルダが作成され、必要なフォルダ構造とファイルが自動的に生成されます。フォルダ構造とファイルの配置は次のようになっています。

  • app
    • controllers
      • Application.scala
    • views
      • index.scala.html
      • main.scala.html
  • conf
    • application.conf
    • routes
  • project
    • build.properties
    • plugins.sbt
  • public
    • images
      • favicon.png
    • javascripts
      • jquery-1.9.0.min.js
    • stylesheets
      • main.css
  • test
    • ApplicationSpec.scala
    • IntegrationSpec.scala
  • .gitignore
  • build.sbt
  • README

沢山のファイルが生成されました。

play run命令を実行してみる

既存のアプリケーションを実行するにはアプリケーションが存在するフォルダでplay run命令を実行します。

c:\work\play\hitotume>..\play run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Getting org.scala-sbt sbt 0.13.0 ...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        43 artifacts copied, 0 already retrieved (12440kB/1375ms)
[info] Loading project definition from C:\work\play\hitotume\project
[info] Set current project to namae (in build file:/C:/work/play/hitotume/)
[info] Updating {file:/C:/work/play/hitotume/}hitotume...
[info] Resolving org.scala-lang#scala-library;2.10.3 ...
  [info] Resolving com.typesafe.play#play-jdbc_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#play_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#sbt-link;2.2.6 ...
  [info] Resolving org.javassist#javassist;3.18.0-GA ...
  [info] Resolving com.typesafe.play#play-exceptions;2.2.6 ...
  [info] Resolving com.typesafe.play#templates_2.10;2.2.6 ...
  [info] Resolving com.github.scala-incubator.io#scala-io-file_2.10;0.4.2 ...
  [info] Resolving com.github.scala-incubator.io#scala-io-core_2.10;0.4.2 ...
  [info] Resolving com.jsuereth#scala-arm_2.10;1.3 ...
  [info] Resolving com.typesafe.play#play-iteratees_2.10;2.2.6 ...
  [info] Resolving org.scala-stm#scala-stm_2.10;0.7 ...
  [info] Resolving com.typesafe#config;1.0.2 ...
  [info] Resolving com.typesafe.play#play-json_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#play-functional_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#play-datacommons_2.10;2.2.6 ...
  [info] Resolving joda-time#joda-time;2.2 ...
  [info] Resolving org.joda#joda-convert;1.3.1 ...
  [info] Resolving com.fasterxml.jackson.core#jackson-annotations;2.2.2 ...
  [info] Resolving com.fasterxml.jackson.core#jackson-core;2.2.2 ...
  [info] Resolving com.fasterxml.jackson.core#jackson-databind;2.2.2 ...
  [info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
  [info] Resolving io.netty#netty;3.7.1.Final ...
  [info] Resolving com.typesafe.netty#netty-http-pipelining;1.1.2 ...
  [info] Resolving org.slf4j#slf4j-api;1.7.5 ...
  [info] Resolving org.slf4j#jul-to-slf4j;1.7.5 ...
  [info] Resolving org.slf4j#jcl-over-slf4j;1.7.5 ...
  [info] Resolving ch.qos.logback#logback-core;1.0.13 ...
  [info] Resolving ch.qos.logback#logback-classic;1.0.13 ...
  [info] Resolving com.typesafe.akka#akka-actor_2.10;2.2.0 ...
  [info] Resolving com.typesafe.akka#akka-slf4j_2.10;2.2.0 ...
  [info] Resolving org.apache.commons#commons-lang3;3.1 ...
  [info] Resolving com.ning#async-http-client;1.7.18 ...
  [info] Resolving oauth.signpost#signpost-core;1.2.1.2 ...
  [info] Resolving commons-codec#commons-codec;1.3 ...
  [info] Resolving oauth.signpost#signpost-commonshttp4;1.2.1.2 ...
  [info] Resolving org.apache.httpcomponents#httpcore;4.0.1 ...
  [info] Resolving org.apache.httpcomponents#httpclient;4.0.1 ...
  [info] Resolving commons-logging#commons-logging;1.1.1 ...
  [info] Resolving xerces#xercesImpl;2.11.0 ...
  [info] Resolving xml-apis#xml-apis;1.4.01 ...
  [info] Resolving javax.transaction#jta;1.1 ...
  [info] Resolving com.jolbox#bonecp;0.8.0.RELEASE ...
  [info] Resolving com.google.guava#guava;14.0.1 ...
  [info] Resolving com.h2database#h2;1.3.172 ...
  [info] Resolving tyrex#tyrex;1.0.1 ...
  [info] Resolving com.typesafe.play#anorm_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#play-cache_2.10;2.2.6 ...
  [info] Resolving net.sf.ehcache#ehcache-core;2.6.6 ...
  [info] Resolving com.typesafe.play#play-test_2.10;2.2.6 ...
  [info] Resolving junit#junit;4.11 ...
  [info] Resolving org.hamcrest#hamcrest-core;1.3 ...
  [info] Resolving org.specs2#specs2_2.10;2.1.1 ...
  [info] Resolving org.scalaz#scalaz-core_2.10;7.0.2 ...
  [info] Resolving org.scalaz#scalaz-concurrent_2.10;7.0.2 ...
  [info] Resolving org.scalaz#scalaz-effect_2.10;7.0.2 ...
  [info] Resolving com.novocode#junit-interface;0.10 ...
  [info] Resolving org.scala-tools.testing#test-interface;0.5 ...
  [info] Resolving com.google.code.findbugs#jsr305;2.0.1 ...
  [info] Resolving org.fluentlenium#fluentlenium-festassert;0.8.0 ...
  [info] Resolving org.fluentlenium#fluentlenium-core;0.8.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-java;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-android-driver;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-remote-driver;2.32.0 ...
  [info] Resolving cglib#cglib-nodep;2.1_3 ...
  [info] Resolving org.json#json;20080701 ...
  [info] Resolving org.seleniumhq.selenium#selenium-api;2.32.0 ...
  [info] Resolving org.apache.httpcomponents#httpclient;4.2.1 ...
  [info] Resolving org.apache.httpcomponents#httpcore;4.2.1 ...
  [info] Resolving commons-codec#commons-codec;1.6 ...
  [info] Resolving org.apache.commons#commons-exec;1.1 ...
  [info] Resolving net.java.dev.jna#jna;3.4.0 ...
  [info] Resolving net.java.dev.jna#platform;3.4.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-chrome-driver;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-htmlunit-driver;2.32.0 ...
  [info] Resolving net.sourceforge.htmlunit#htmlunit;2.12 ...
  [info] Resolving xalan#xalan;2.7.1 ...
  [info] Resolving xalan#serializer;2.7.1 ...
  [info] Resolving commons-collections#commons-collections;3.2.1 ...
  [info] Resolving org.apache.httpcomponents#httpmime;4.2.3 ...
  [info] Resolving net.sourceforge.htmlunit#htmlunit-core-js;2.12 ...
  [info] Resolving net.sourceforge.nekohtml#nekohtml;1.9.18 ...
  [info] Resolving net.sourceforge.cssparser#cssparser;0.9.9 ...
  [info] Resolving org.w3c.css#sac;1.3 ...
  [info] Resolving commons-io#commons-io;2.2 ...
  [info] Resolving org.eclipse.jetty#jetty-websocket;8.1.9.v20130131 ...
  [info] Resolving org.eclipse.jetty#jetty-util;8.1.9.v20130131 ...
  [info] Resolving org.eclipse.jetty#jetty-io;8.1.9.v20130131 ...
  [info] Resolving org.eclipse.jetty#jetty-http;8.1.9.v20130131 ...
  [info] Resolving org.seleniumhq.selenium#selenium-firefox-driver;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-ie-driver;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-iphone-driver;2.32.0 ...
  [info] Resolving org.seleniumhq.selenium#selenium-safari-driver;2.32.0 ...
  [info] Resolving org.webbitserver#webbit;0.4.14 ...
  [info] Resolving org.seleniumhq.selenium#selenium-support;2.32.0 ...
  [info] Resolving org.easytesting#fest-assert;1.4 ...
  [info] Resolving org.easytesting#fest-util;1.1.6 ...
  [info] Resolving com.typesafe.play#play-docs_2.10;2.2.6 ...
  [info] Resolving com.typesafe.play#play-doc_2.10;1.0.3 ...
  [info] Resolving org.pegdown#pegdown;1.4.0 ...
  [info] Resolving org.parboiled#parboiled-java;1.1.5 ...
  [info] Resolving org.parboiled#parboiled-core;1.1.5 ...
  [info] Resolving org.ow2.asm#asm;4.1 ...
  [info] Resolving org.ow2.asm#asm-tree;4.1 ...
  [info] Resolving org.ow2.asm#asm-analysis;4.1 ...
  [info] Resolving org.ow2.asm#asm-util;4.1 ...
  [info] Resolving commons-io#commons-io;2.4 ...
  [info] Resolving org.scala-lang#scala-compiler;2.10.3 ...
  [info] Resolving org.scala-lang#jline;2.10.3 ...
  [info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.

--- (Running the application from SBT, 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...)

Webサーバが起動したようですね。Webブラウザからhttp://localhost:9000/に接続しましょう。

[info] Compiling 5 Scala sources and 1 Java source to C:\work\play\hitotume\target\scala-2.10\classes...
[info] play - Application started (Dev)

ページが表示されました。

1
1
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
1
1