This compilation unit is not on the build path of a Java project

后端 未结 8 810
后悔当初
后悔当初 2020-12-24 05:39

When I try to use ctrl+space this error is shown:

This compilation unit is not on the build path of a Java project.

I see tha

相关标签:
8条回答
  • 2020-12-24 05:53

    If it is a Maven project then sometimes re-importing of it helps:

    1. Right-click the project in the Project Explorer and choose Delete.
    2. File > Import... > Maven > Existing Maven Projects > Next > Root Directory > Browse your project from Disk.

    Hope it will resolve the issue.

    0 讨论(0)
  • 2020-12-24 05:56

    In my case, I have Eclipse Maven project. I had the same issue and I posted detailed explanation of the issue and answer here Eclipse Maven - Code Completion fails "This compilation unit is not on the build path of a Java project" and "Failed to Download Index" Error

    0 讨论(0)
  • 2020-12-24 06:00

    If your project is imported as an existing maven project then --> Just right click on project and do maven update. It resolved my similar issue.

    0 讨论(0)
  • 2020-12-24 06:01

    Another alternative to Loganathan Mohanraj's solution (which effectively does the same, but from the GUI):

    1. Right-Click on your project
    2. Go to "Properties"
    3. Choose "Project Natures"
    4. Click on "Add"
    5. Choose "Java"
    6. Click "Apply and Close"
    0 讨论(0)
  • 2020-12-24 06:15

    Since you imported the project as a General Project, it does not have the java nature and that is the problem.

    Add the below lines in the .project file of your workspace and refresh.

    <natures>
          <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
    
    0 讨论(0)
  • 2020-12-24 06:15

    Go to Project-> right Click-> Select Properties -> project Facets -> modify the java version for your JDK version you are using.

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