Play create new application

Create a new application with the Play standalone distribution

The Play standalone distribution comes with a script called play, which can easily be used to create a new application.

$ play new myFirstApp

This will ask for some information.

  • The application name (just for display, this name will be used later in several messages).
  • The template to use for this application. You can choose either a default Scala application or a default Java application.

Note that choosing a template at this point does not imply that you can’t change language later. For example, you can create a new application using the default Java application template and start adding Scala code whenever you like.

Once the application has been created you can use the play command again to enter the Play console .

$ cd myFirstApp
$ play

Create a new application without having Play installed

You can also create a new Play application without installing Play, by using sbt.

First install sbt if needed.

Just create a new directory for your new application and configure your sbt build script with two additions.

In project/plugins.sbt, add:

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.x")

Be sure to replace 2.2.x here with the exact version you want to use. If you want to use a snapshot version, you will have to specify this additional resolver:

// Typesafe snapshots
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"

In build.sbt:

import play.Project._

name := "My first application"

version := "1.0"

playScalaSettings

You can then launch the sbt console in this directory:

$ cd myFirstApp
$ sbt

sbt will load your project and fetch the dependencies.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值