O'Reilly logo

RESTful Web Services with Scala by Jos Dirksen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello World with Play 2

To create a simple Hello World REST service in Play 2, we first need to set up the SBT project correctly. Play 2 uses an SBT plugin to run an HTTP server that you can use to access your REST service. The first thing we need to do is add this plugin to the plugins.sbt file (which you can find in the project directory):

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

Next, we define the dependencies so that we can create a Play 2-based REST service. For Play 2, we use the following dependencies:

lazy val playVersion = "2.4.0"

val backendDeps = Seq (
  "com.typesafe.play" %% "play" % playVersion,
  "com.typesafe.play" %% "play-docs" % playVersion
)

There is one more step we need to add to the SBT configuration (build.sbt ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required