6
votes

I've created a Play-java [v 2.4.2] project with using activator[v 1.3.5] that uses JDK 1.8 on Windows 64-bit OS. I've run activator run command and it works smoothly.

But when I open that project in Intellij Idea [v 14.1.4] IDE not working properly; warns me in controller and view files as follows: Intellij IDEA 14.x controller

and this:

Intellij IDEA 14.x view

And it says: 'Cannot resolve symbol ...'

I googled this and find some useful links, included a few stackoverflow Q&A's, i.e: Play framework tutorial: Cannot resolve symbol 'index'?

I've Scala and Play plugins and in this path ([File -> Project Structure -> Modules -> [MyAppModule] -> Sources Tab]) there is no "target/scala-[version]/src_managed" directory. Look this:

Intellij IDEA 14.x project structure

In this Intellij Idea or Play version, something's changed.

I've tried some combinations for making folders as source folder or excluded. I've used IDE's option: 'Invalidate Caches/Restart'. None of them worked for me.

How can I fix this issue?

2
Do you have Scala plugin?Mon Calamari
I've already write that inside my question: 'I've Scala and Play plugins...'Oguz Ozkeroglu
I get that sometimes - Try right-clicking the project, select "Add Framework Support" and select "Play 2.x" and click OK.dcastro
Did you imported this project as a SBT Project?adis
did you performed all steps from this page: playframework.com/documentation/2.2.x/IDEMichał Wolnicki

2 Answers

6
votes

Finally I've got the solution. Here are the steps that I followed:

  • Create a play-java project using activator.
  • Import that project as an SBT project to Intellij Idea.
  • Right click on project then select "Add Framework Support" and then select "Play 2.x"
  • Build -> make project.

Now everything works fine.

4
votes

For play project, you have to let Intellij know this is a SBT project.

File -> Open -> select the .sbt file under the root directory of your project. It will take Intellij a while to resolve the project and download dependencies.

In addition, from my personal experience, you should use activator new to create a new Play project and import that project into Intellij rather than directly creating a Play project usingn Intellij Play plugin. Sometimes, the plugin does not work properly.