It’s been a while since I picked up the Play Framework. I wanted to create a new Play 2 project in IDEA. I used the Play 2 plugin to create a new project.
**But, **I am great believer in getting a project created at the command-line. Maybe it's something to do with production servers not running IDEA :O)
This is a step-by-step guide to importing your Play 2 project into IDEA:
First of all, check that nothing is running on http://localhost:9000 this is the default port for running Play 2 applications. _Make sure that you uninstall previous (old) versions of the Play Framework (binary), especially **before** activator was used (**pre** Play version 2)._
Create a new Play 2 project, named Foo.
Type activator foo (select** 5** for a play-java project):
Now start the activator ui (user-interface). This will allow you to run the Foo project from the activator web-ui:
The activator web-ui will “appear” (on http://localhost:8888)
Click the Run icon. Then select the Run option (on the left vertical navigation):
Point your web-browser at 9000. You will see the “Welcome to Play” web-page.
**Import the Foo Play 2 application into IDEA 14**
Stop the activator ui (Java) process. Ensure that http://localhost:9000 is not being used (by Play 2).
Start IDEA 14, and Create New Project from Existing Sources:
Select the build.sbt file from the Foo project:
The next screen will “confirm” that you are importing an SBT project:
Don’t bother ticking any of the options. Ensure that the Project SDK (Java) is correct.
When dependencies have been imported, you will see a “typical” Play project file structure:
At this stage, I always select the Build -> Rebuild menu option. This ensures that everything compiles (works).
I then select main.scala.html (this is the naming convention), right click, and select Run Play 2 App:
Please be patient. It takes a while to Play 2 to be listening on port 9000. You are looking for this text (the same as in the activator ui task - previously):
http://localhost:9000 will show you the same welcome message:
**Congratulation on getting your Play 2 application successfully imported into IDEA 14 :O)**
It is important to have the correct plugins installed in IDEA.
I have just been-through the tutorial, and have taken additional screen-shots of my project configuration, and the Plugins which I have installed:
Firstly, I am showing my Play 2, Edit Configurations:
Then my IDEA Plugins:
Plugins are Playframework Support, and Scala. The Scala Plugin has the Play 2 support.
Please ensure that these plugins are installed.