Filip Bouška
Filip Bouška

Reputation: 141

Idea + Play Framework - cannot resolve method/symbol

I use IntelliJ IDEA 12, Play 2.2.0, I have Scala plugin installed, Play 2.0 support plugin installed.

I created java play application via termina (play new). Andas you can see in this pictures I always get this error: "cannot resolve method ok()" or "cannot resolve symbol at"

http://sluchatka.kvalitne.cz/pics/1.png

http://sluchatka.kvalitne.cz/pics/2.png

I searched the web for this problem the whole day, but I didn't find solution. Can you please help me?

Upvotes: 9

Views: 5460

Answers (4)

abbas
abbas

Reputation: 7071

This click in the Project Structure is your answer.

enter image description here

Upvotes: 0

Ben
Ben

Reputation: 2523

I was having a similar issue with Play 2.4.2 and Intellij 14.1.4. I could run the basic "play-java" example/starter app in Intellij, even though the editor showed errors like "cannot resolve method ok()".

Here's what solves the problem for me:

  1. Before starting, make sure your project is not open in Intellij.

  2. Delete the ".idea" folder from your existing app, OR just create a new app using "activator new".

  3. On the command line, cd to the app's folder and compile using "activator compile".

  4. In Intellij, File -> Open, and select your app's folder. For the SBT import options, I left the boxes unchecked (e.g. "Use auto-import", "Create directories for empty content roots automatically", etc.) but I don't think it matters.

Once everything finishes loading, you shouldn't see the errors any more.

Upvotes: 2

Andreas
Andreas

Reputation: 533

According to intelliJ support it is better to import the command line created play 2 project using the IDE import project wizard instead.

  1. File -> Import Project
  2. Select play2 project location
  3. Import as SBT project

This was due to the "play idea" command being outdated or not fully compatible with the current play 2 and scala plugins for intelliJ.

A bonus is that errors start to appear properly, we had trouble with that earlier.

Upvotes: 4

kompot
kompot

Reputation: 798

The first problem (unable to resolve reference to template) is because your template probably has not been compiled by the moment (and thus IDEA does not see compiled template and can't resolve reference to it).

I usually develop Play apps having ~run command launched in Play console. So that any changes to templates are immediately compiled and changes detected by IDEA.

As for the second one it seems like a deficiency in Play IDEA plugin. It does not work seamlessly within templates I should say. Lots of glitches. The best way I found is to have ~run launched so that small problems are detected immediately.

Upvotes: 4

Related Questions