Eclipse not recognizing Scala code

前端 未结 11 2637
说谎
说谎 2021-02-18 19:20

I have Eclipse Indigo with the Scala IDE plugin. I downloaded a lift project from Maven. It builds correctly. Eclipse says it is viewing it with the Scala editor.

How

相关标签:
11条回答
  • 2021-02-18 19:26

    This problem can show up when you copy an existing java project to start a new project or use a project file generator.

    One thing you can look at is your Java Build Path inside project properties. Make sure your scala source folder doesn't have an include filter like **/*.java. Make sure it is **/*.scala or remove it and your source should be detected by the scala plugin.

    0 讨论(0)
  • 2021-02-18 19:26

    My Java Classes refuse to recognize my Scala ones. However when I do a "Ctrl + Click" = Open Declaration, it goes to the right place. My Java Classes that depend on Scala look like Red all over. I checked Build Path settings etc, they all look ok.

    I had the same problem. When I moved my Scala classes to the correct package folder, it worked. Scala does not need this. But only that way Java editor reconized the Scala class.

    0 讨论(0)
  • 2021-02-18 19:27

    Open the Package Explorer, look at your scala source. Does the icon displays a S (for Scala), or a J (for Java)?

    If you see a S, then you are likely missing the Scala Nature. As Luigi suggested, try to add the Scala Nature and see if that fixes your issue (Right-click on project, Configure > Add Scala Nature.)

    Otherwise, if you see a J, the odds are that "JDT Weaving" is not enabled. That should not happen and might depend on other plugins you have installed.

    What I would try if I were you is simply uninstalling all Scala IDE plugins from Eclipse ("Scala IDE for Eclipse", and also the "JDT Weaving for Scala" if you see it in the list of installed plugins). Then, reinstall Scala IDE 2.0.0-RC04. I know, it's not the ideal solution, but it's hard to tell what is going on without more information.

    If that doesn't work either, please write a message in the scala-ide-user Mailing List. Make sure to provide the full list of plugins you have in your Eclipse installation. That might help us understand what is going on.

    0 讨论(0)
  • 2021-02-18 19:28

    I use Maven to generate my jar. So followed the steps below Right click on project -> Maven -> Update Project -> Check force Update of Snapshots/Releases -> OK

    0 讨论(0)
  • 2021-02-18 19:29

    I solved the problem with compile/build errors with sbt-eclipse by

    1. Right-click project
    2. Scala menu -chose New Scala Installation and select version until no errors were listed
    0 讨论(0)
  • 2021-02-18 19:32

    I have similar issues, though when I remove the Scala Nature and Add it back it becomes ok. Which is fine for now.

    But there is another issue:

    My Java Classes refuse to recognize my Scala ones. However when I do a "Ctrl + Click" = Open Declaration, it goes to the right place. My Java Classes that depend on Scala look like Red all over. I checked Build Path settings etc, they all look ok.

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