Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program

前端 未结 6 937
再見小時候
再見小時候 2020-12-28 08:43

I\'ve created a Play Framework program via Typesafe Activator (so it follows the template exactly).

I used sbteclipse-plugin version 3.0.0 to create an

相关标签:
6条回答
  • 2020-12-28 09:06

    Update: Just upgrade to sbteclipse version 5.1.0 and everything should work out of the box. Also make sure you follow the Play documentation on how to set up Eclipse/ScalaIDE.


    This is a known bug in sbteclipse, which probably will be fixed soon.

    For now, you can add the following line to your build.sbt:

    EclipseKeys.createSrc := EclipseCreateSrc.All
    

    Kill the SBT console and run sbt eclipse again. That should add the following line to the .classpath file within your project folder as a workaround:

    <classpathentry kind="src" path="target/scala-2.11/twirl/main"/>
    

    Refresh your Eclipse project to pick up the change.

    0 讨论(0)
  • 2020-12-28 09:09

    I tried @mkurz solution first, but also ran into the same error as @matt. I became frustrated that I could not generate the eclipse project without having to go to the Eclipse project properties to manually fix the build errors. After some investigation, I discovered the solution that removed all errors entirely. Add this your build.sbt:

    unmanagedSourceDirectories in Compile <+= twirlCompileTemplates.target
    

    Or if that does not work for you, you could also use:

    unmanagedSourceDirectories in Compile <+= target.zipWith(scalaBinaryVersion) { (b,v) => b / s"scala-$v/twirl/main" }
    

    Good bye, build errors!

    0 讨论(0)
  • 2020-12-28 09:09

    For me, it turned out that installed JRE in the Scala IDE was openjdk, changed it to Oracle Java 8 and it worked.

    0 讨论(0)
  • 2020-12-28 09:14

    If, after following Mkurz' instructions (adding EclipseKeys.CreateSrc... ), your problems are not solved, click on Project -> Properties -> Java Build Path. Look at the source folders tab.

    You may find a duplicate file folder named .../src_managed/main (Thanks Matt). If so, close the project. Remove ONE of the two ../src_managed/main entries from the .classpath file (located in the base of the activator/SBT project directory). Reopen and clean the project and you should be good to go.

    0 讨论(0)
  • 2020-12-28 09:22

    I got the same error message. Are you using java8 as jre in eclipse? After switching back from java8 to java7, everything worked fine again.

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

    I had the same issue, also with Scala IDE 4.0.0 . I followed mkurz instuctions and they worked like a charm. But instead of changing the .classpath file in the project folder manually I used Eclipse interface:

    • In the top menu of the main window, click on Project and then on Properties.
    • In the Properties window, click on Java Build Path option (options list is on the left)
    • In the Source tab, click on Add Folder... button.
    • In the Source Folder Selection window, choose the target/scala-2.11/twirl/main folder, so it is included in the compilation path. Click Ok button.
    • Click Ok in the Properties window.

    Now the project should compile just fine :) . With that I was able to finish the play setup example in Scala IDE website

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