简体   繁体   中英

Setup Play 2.2.1 and IntelliJ 12.0.4

I am running on OSX 10.9. I have downloaded Play 2.2.1 and want to use IntelliJ 12.0.4. for development. I set it up by running play in the directory of the project followed by idea with-sources=yes followed by a compile .

I can run the project from the terminal and from IntelliJ without any problems. All the changes I make to the files are reflected in the browser when the project is recompiled.

What troubles me is that IntelliJ cannot resolve the views which makes its auto-complete function useless. The error is "Cannot resolve method ok(?)/Cannot resolve symbol index".

I have read a great deal of material on the matter but to no avail. I would be grateful if anyone points out a step I am missing.

I have had this problem on occasion; unfortunately I can't reproduce it now with any of my Play 2.2 projects, but I remember having to do this to get the views to resolve:

  • Go to the Module Settings for your project in IntelliJ (select the top-level, hit F4)
  • Choose the Modules item in the Project Structure window that appears
  • Select the <projectname> item (as opposed to the <projectname>-build ) item
  • Add the compiler's output views directory to the Source Folders items;
    • I'm in Scala so for me it's target/scala-2.10/classes/views
    • I'm sure it'll be something fairly similar in Java - probably target/classes/views ?
    • I personally find the IntelliJ UI for this to be very non-intuitive; you might need to take the target directory and/or one of its subdirectories out of the Excluded Folders first
  • After applying that change, IntelliJ should see those view files as just-another source file, so auto-complete should work for them.

Also it might be that the Intellij you are using is not the Ultimate Edition .

The community edition does not support Play Framework versions lower than 2.4.x

look for 'play' here: https://www.jetbrains.com/idea/features/editions_comparison_matrix.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM