My method in my Application-class shows an error in IntelliJ that isn't an error. The method works fine in my browser and as you know (if you're familiar with Play) compile-errors will show in your browser when you run the program. My method works just as planned, but the error-indication in the IDE won't go away.
If you use Eclipse (Scala IDE) you just run the
activator eclipse command in the command-line and the IDE won't complain anymore - is there a similar fix for IntelliJ?
Edit: I use Play 2.4, so the
activator idea command doesn't work either: Play Framework 2.4 and IntelliJ Idea
Edit 2: Not a duplicate of IntelliJ Ultimate can't find routes in Play 2.3 (Java) project tests because that one is about the IDE not finding routes, and mine is about wrong error-indication with different solutions to different problems. For the correct solution see the accepted answer.
IDEA 14.1.3 doesn't set the classpath correctly when importing a Play 2.4 application. By default
target folder is excluded from the classpath. However the twirl templates and routes are compiled to the target folder and need to be available to the classpath.
To fix the issue
- Make sure your classes and templates are compiled:
Build > Make
File > Project Structure
- Go to
Modulesmenu and select the
- Go to the
- Remove the
targetfolder from the excludes by clicking on the
Xnext to it in the right panel
- Click Apply
You can then see that
target\scala-2.11\twirl\main are recognized as source folders properly.
Your error should then go away.