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

前端 未结 24 2908
故里飘歌
故里飘歌 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:27

    Your source files should be in a structure with a 'package' icon in the Package Explorer view (in the menu under Window > Show View > Package Explorer or press Ctrl+3 and type pack), like this:

    If they are not, select the folder containing your root package (src in the image above) and select Use as Source Folder from the context menu (right click).

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

    I had same issue after importing maven project consisting of nested micro services. This is how I got it resolved in Eclipse:

    1. Right Click on Project
    2. Select Configure
    3. Select "Configure and Detect Nested Projects"
    0 讨论(0)
  • 2020-12-08 04:28

    When you have a multimodules maven project under a parent project, make sure you're not editing the file in the maven parent project.

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

    If you're a beginner (like me), the solution may be as simple as making sure the parent folder that the file you're working in is a Java project.

    I made the mistake of simply creating a Java folder, then creating a file in the folder and expecting it to work. The file needs to live in a project if you want to avoid this error.

    0 讨论(0)
  • 2020-12-08 04:29
    1. Delete your project (DO NOT DELETE THE ORIGIN FILE IN THE FILE SYSTEM)
    2. Right click at Package explorer area and right click import.
    3. Go to Maven folder and hit import an existing maven project.

    Hope it helps

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

    This is what was missing in my .project file:

        <projectDescription>
            ...
            <buildSpec>
                <buildCommand>
                    <name>org.eclipse.jdt.core.javabuilder</name>
                    <arguments>
                    </arguments>
                </buildCommand>
            </buildspec>
            ...
            ...
            ...
            <natures>
                <nature>org.eclipse.jdt.core.javanature</nature>
                <nature>org.eclipse.m2e.core.maven2Nature</nature>
            </natures>
            ...
        </projectDescription>
    
    0 讨论(0)
提交回复
热议问题