IntelliJ IDEA Report Highlighting error when using routes in Controller

前端 未结 2 2152
轻奢々
轻奢々 2020-12-07 12:05

I have a Scala Play project. I\'m using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 12:49

    This is a common problem, it's because IntelliJ needs to be shown where to look for the compiled Scala templates and routes file. Here's how I fixed it on my IntelliJ 12.1 installation:

    • Go to the Module Settings for your project in IntelliJ (select the top-level, hit F4)
    • Choose the Modules item in the Project Structure window that appears
    • Select the projectname item (as opposed to the projectname-build item)
    • Add the compiler's output directory to the Source Folders items;
      • For Scala 2.10 it's target/scala-2.10/classes
      • I personally find the IntelliJ UI for this to be very non-intuitive; you might need to take the target directory and/or one of its subdirectories out of the Excluded Folders first
    • After applying that change, IntelliJ should see the results of compiling each routes and .scala.html file as just-another source file, so they won't show as "broken" and auto-complete should work for them.

提交回复
热议问题