Eclipse “this compilation unit is not on the build path of a java project”

前端 未结 24 2905
故里飘歌
故里飘歌 2020-12-08 03:41

I can\'t get autocompletion to work on Eclipse.

I\'m working on the project on svn. I set up project in Eclipse by going into

File -> Import -> Checkout As

相关标签:
24条回答
  • 2020-12-08 04:23

    I found that I was getting this error due to having my files, including my main class, outside of the .src folder.

    0 讨论(0)
  • 2020-12-08 04:23

    Run "mvn eclipse:eclipse" from terminal.

    0 讨论(0)
  • 2020-12-08 04:25

    I did copy the .classpath and .project from another project and adjusted the values properly.

    Close the project before editing those files, when you are sure they reflect the reality (your reality anyway), re-open the project in Eclipse.

    The workspace is rebuilt and all should work from then on.

    0 讨论(0)
  • 2020-12-08 04:26

    I also had this problem after converting my java project into a maven project. I solved it as follows:

    Right click on your project ->Project Facets -> click on Java, then Apply.

    0 讨论(0)
  • 2020-12-08 04:26

    I might be picking up the wrong things from so many comments, but if you are using Maven, then are you doing the usual command prompt build and clean?

    Go to cmd, navigate to your workspace (usually c:/workspace). Then run "mvn clean install -DskipTests"

    After that run "mvn eclipse:eclipse eclipse:clean" (don't need to worry about piping).

    Also, do you have any module dependencies in your projects?

    If so, try removing the dependencies clicking apply, then readding the dependencies. As this can set eclipse right when it get's confused with buildpath sometimes.

    Hope this helps!

    0 讨论(0)
  • 2020-12-08 04:26

    What i did is after importing the project from svn , deleted the project from workspace and imported it as a maven project from local . Then in preferences->maven->usersettings->in usersettings box gave path of settings.xml which will be in apache maven folder-> conf->settings.xml

    and it solved the issue for me.

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