Getting Started with Play 2.x
Before you start generating your Play project, make sure that the Scala plugin is downloaded and enabled in IntelliJ IDEA.
IntelliJ IDEA support Play versions 2.4 and later. Note that Play framework is supported in the IntelliJ IDEA ultimate edition only.
Let's look at the following common scenarios for generating a Play 2 project in IntelliJ IDEA:
- If you have an already existing Play 2 project, you can import or check out from version control. In this case you can follow the regular procedure for importing or cloning a project.
- If you are not familiar with Play framework and want to learn how to use it, you can create a Play project via IntelliJ IDEA that will generate a "ready-to-run" application.
- If you want to see what types Play 2 projects can be generated you can use Lightbend Project Starter and create a project using one of the offered templates.
- If you want to manually add a support for Play 2 framework, you can create an sbt project.
Creating a new Play 2 project
- Open New Project wizard. From the options on the right, select Play 2.x.
- Follow the steps suggested in the wizard and click Finish.
IntelliJ IDEA generates the Play 2 project with the appropriate structure, dependencies and an executable application.
Creating a Play 2 template with Lightbend project starter
- Open a new project wizard and from the options on the right, select Lightbend Project Starter.
- On the next page of the wizard select the Play Scala Seed template that will create an executable Play template project for developing your Play application. Click Finish.
Creating an sbt project with Play 2 framework
- Create an sbt project. Follow the steps suggested in the wizard and click Finish.
IntelliJ IDEA creates an sbt project.
- Open the
build.sbtfile in the editor and add Play as project dependency.
- In the Project tool window, in the project source root directory, select to create the
- Open the plugins.sbt file in the editor and add the Play plugin.
IntelliJ IDEA downloads the appropriate dependencies and adds them to the Dependencies node in the sbt projects tool window.
Please note that the Play framework project structure is not generated and you need to add everything manually. Check the Play 2 project structure.
At this point you can start creating Play 2 templates since IntelliJ IDEA supports them as soon as support of Play framework is added and develop your project further. You can use code completion, navigation and on-the-fly code analysis features in your Play files. IntelliJ IDEA also supports code assistance for routes files and code inspections.
Running and debugging Play 2 application
- In the project tool window, right-click the application.
- On the context menu, select Run Play 2 App.
If you want to stop the server, press Alt+D (Cmd+P for macOS).
- On the main menu, select .
- From the list that opens, select Edit Configurations.
- In the dialog that opens, specify settings for debugging or use the default ones and press OK. IntelliJ IDEA will start a debugging session.