“object index is not a member of package views.html” when opening scala play project in scala ide

前端 未结 11 979
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 01:36

I\'ve created a play project with play 2.3.7

In the project directory, I ran activator and ran the eclipse command to generate eclipse project files.

相关标签:
11条回答
  • 2020-12-09 02:12

    @brent-foust 's answer worked for me but only initially. Every time I rebuilt the project from within IDEA I would then get "not found: routes" errors from within target\scala-2.11\twirl\main\views\html\main.template.scala until I performed Brent's workaround again.

    I eventually discovered the solution to that was changing a line in the .iml file from

    <excludeFolder url="file://$MODULE_DIR$/target/scala-2.11/src_managed/main" />
    

    to

    <sourceFolder url="file://$MODULE_DIR$/target/scala-2.11/src_managed/main" isTestSource="false" />
    

    I don't know what the long term implications of doing this are but it has fixed this problem. Some of the other similar problems mentioned might also be fixed by applying the same change to some of the other folders listed in the .iml.

    0 讨论(0)
  • 2020-12-09 02:15

    I tried all solutions without any positiv result.
    So I went to Preferences > Build, Execution, Deployment > Build Tools > sbt and checked Use sbt shell for imports and builds.
    This let the compile button in intelliJ compile with the sbt shell. I think this is better anyway, since a build server or something similar will compile the same way and not like intelliJ.

    0 讨论(0)
  • 2020-12-09 02:17

    I had the same problem. I added target/scala-2.x/classes and target/scala-2.x/classes_managed to my Java build path and Eclipse stopped complaining.

    0 讨论(0)
  • 2020-12-09 02:18

    Occasionally after adding a view in Play 2.4.x, IntelliJ IDEA sometimes gets confused and absolutely refuses to build. Even rebuild Project fails:

    This still happens from time-to-time in IDEA 15. And when it does, the command line provides the quickest, most-reliable fix:

    sbt clean; sbt compile

    That's it! IDEA will now compile the project as expected.

    Update:

    In the rare case that sbt compile completed successfully on the command line, but IntelliJ IDEA 15 still gives the same "object x is not a member" error, then this has solved IDEA's confusion:

    File Menu:

    0 讨论(0)
  • 2020-12-09 02:18

    For me when importing the project into intellij making sure I "checked" the "auto import" checkbox did the trick.

    0 讨论(0)
  • 2020-12-09 02:21

    In Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program you can find the solution (in brief: adding target/scala-2.11/twirl/main folder to the compilation path), give it a try.

    0 讨论(0)
提交回复
热议问题