Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA can not resolve symbol with Play framework

I am using IDEA 13 with Play 2.2.1 and was doing the examples on the play site.

public static Result index() {    return redirect(routes.Application.tasks()); } 

IDEA says "cannot resolve method redirect(?)" and red underlines routes.Application.tasks()

I have done "compile" and then "idea" from the play console.

like image 412
Pavan K Mutt Avatar asked Feb 05 '14 12:02

Pavan K Mutt


People also ask

How do I add play framework to IntelliJ?

Create an sbt project with Play 2 framework IntelliJ IDEA creates an sbt project. Open the build. sbt file in the editor and add Play as a project dependency. In the Project tool window, in the project source root directory, select New | File to create the plugins.


1 Answers

I had a similar problem when testing my controller. I solved it by "File" > "Open Project" and choose the base folder of the Play framework project (delete all idea settings file from the folder before so that it will reimport using the SBT settings).

The last version of the SBT support for IDEA did 90% of the work. Then F4 to enter module settings dialog. Set up your project dependencies like in the picture below (the bright red folder have been set by IDEA and do not exist yet in my project so do not worry if they do in yours). It is a matter of including managed classes and generated code in the code that idea will use and index.

enter image description here

now I can use code like this from within IDEA and debug it no problem.

Result result = Helpers.callAction(controllers.routes.ref.CrudController.createEntity(CrudEntities.contact.name()),         new FakeRequest().withJsonBody(paramJson) ); 

your way of doing it should work as well.

like image 141
le-doude Avatar answered Sep 22 '22 10:09

le-doude