Setup Play Application
Instructions for setting up a Scala development environment with the Play Framework and an IDE.
Building the starter project
- Install a Java Development Kit (JDK) from Oracle (this is a link to Java 8, but you can install anything up to 11)
- Install the Scala Built Tools (SBT), instructions for Mac, Linux and Window can be found here
- Open a terminal/command prompt in the location you want to create your project.
- Run the following command
sbt new playframework/play-scala-seed.g8
This instruction can be found on the play framework getting started site. - Navigate to the top level directory of the project. (the one with build.sbt) In the case of the example this is play-scala-seed.
- Run
sbt run
and open a browser and navigate to localhost:9000 - If everything works, you should see a Welcome to Play! message.
Working with the IntelliJ IDE
-
Download the Intellij community edition (free) IDE for your operating system. Instructions can be found on the jetbrains website here
-
Open the preferences and install the scala plugin (screenshot below)
- Click on File > Open... and navigate to the project folder. Click on the build.sbt file and then open. You will be given 3 options:
-
Choose Open as Project (this is critical to get the IDE to recognise this as a Scala project and have intelli-sense work correctly)
-
You will be given an option to Import Project from sbt. Leave the options at default and click OK.
- At the top of the IDE there is an option to Add Configuration (this is for building and running).
- Click the + symbol and choose sbt Task from the list.
- For the Name: and Tasks: type in
run
- You can now click on the play button to run the application from the IDE.