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

前端 未结 11 985
隐瞒了意图╮
隐瞒了意图╮ 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:23

    Basically we need a way to put the compiled classes on the path for this to work.

    I did the following to fix it. Since the projects compiles to the target directory. I went to the Project Properties -> Java Build Path and added a few folders that look like this,

    target/scala-2.12/routes/main target/scala-2.12/twirl target/scala-2.12/twirl/main

    Now i dont want you to assume you will have these exact folders in your case too. That depends on your project setup. But you should add the folders inside the target/scala-2.x folder.

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

    Adding target/scala-2.11/twirl/main which is having views.html package to source fixed for me.

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

    1) Add the following line to your sbt.build file:

    EclipseKeys.preTasks := Seq(compile in Compile)
    

    2) Add the follwing line to your plugins.sbt file under the project folder:

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
    

    3) Run the "eclipse" command from within sbt

    as explained in the documentation of the play framework:

    Setting up your preferred IDE

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

    The other solutions did not work for me. Some would give me different errors, some would clear the Problems tab but leave me with a red squiggle under views.html.index and auto-complete would not work with the scala.html templates.

    What finally worked was to open the project's properties, go to Java Build Path > Source, and add both of the following directories:

    target/scala-2.11/src_managed/main
    target/scala-2.11/twirl/main
    

    If you only do target/scala-2.11/twirl/main then you'll miss out on the class files generated from the conf directory.

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

    I had the same issue running Play 2.4.0-RC1 using default SBT layout (disablePlugins(PlayLayoutPlugin)) and solved it by adding to build.sbt:

    sourceDirectories in (Compile, TwirlKeys.compileTemplates) :=
        (unmanagedSourceDirectories in Compile).value
    
    0 讨论(0)
提交回复
热议问题