-->

IntelliJ Ultimate can't find routes in Play 2.

2019-02-19 04:24发布

问题:

While my tests run just fine, IntelliJ complains that it can't find the routes object and code auto complete fails to work. I've looked all over the documentation and this should just work. Here is what IntelliJ is reporting

Any thoughts as to what might be wrong with my project configuration?

回答1:

Most likely it's connected with the fact that the routes object is generated during project compilation. After compilation, it should be placed under the target/scala-{ver}/src_managed directory. Mark this directory as source and IntelliJ should see routes correctly.

You can use one of the following steps to do it:

  • right-click the directory in the Project view and select Mark Directory As -> Generated Sources Root

or

  • open File -> Project Structure... -> Modules -> Sources and mark the src_managed directory as Sources using the button above the project structure


回答2:

Actually your question motivated me to find solution for this annoying issue :)

And actually it was already answered, see this answer which works: https://stackoverflow.com/a/21879374/1066240

Also read other answers and comments.