Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove error-indication in IntelliJ in Play Framework project

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.

like image 887
KollKode Avatar asked Mar 29 '26 15:03

KollKode


1 Answers

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

  1. Make sure your classes and templates are compiled: Build > Make
  2. Open File > Project Structure
  3. Go to Modules menu and select the root module
  4. Go to the Sources tab
  5. Remove the target folder from the excludes by clicking on the X next to it in the right panel
  6. Click Apply

You can then see that target\scala-2.11\routes\main and target\scala-2.11\twirl\main are recognized as source folders properly.

Your error should then go away.

like image 142
Alexander B Avatar answered Mar 31 '26 04:03

Alexander B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!