IntelliJ IDEA Report Highlighting error when using routes in Controller

前端 未结 2 2156
轻奢々
轻奢々 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:50

    millhouse's answer helped me find the right answer. Play 2.2 (and perhaps earlier versions, haven't checked) output a scala version of the routes file to project_dir/target/scala-2.10/src_managed/main So for IntelliJ to get the highlighting right you need to make sure that src_managed/main is added as a source folder. The reverse routes for javascript are for some reason included in project_dir/target/scala-2.10/classes_managed so you'll have to add that as well. (In your screenshot it looks like classes_managed is set to excluded so you'll want to un-exclude it by pressing the x button on the right hand side.)

    Here's a screen shot of my project structure:

    Working Play 2.2 project structure

    Update:

    In Play 2.3 (or perhaps recent versions of IntelliJ) adding the classes_managed no longer fixes the problem. Instead of adding classes_managed to the project's sources add it to it's dependencies. By doing that IntelliJ should be able to pick up the compiled routes.class.

    Working Play 2.3 dependency list

提交回复
热议问题