Eclipse+Maven src/main/java not visible in src folder in Package Explorer

前端 未结 16 1972
情深已故
情深已故 2020-12-23 09:19

I\'m wondering why I can\'t see following folders in src node in Package Explorer

src/main/java
src/main/resources
src/test/java
src/test/resources


        
相关标签:
16条回答
  • 2020-12-23 09:36

    Right click the Maven Project -> Build Path -> Configure Build Path Go to Order and Export tab, you can see the message like '2 build path entries are missing' Now select 'JRE System Library' and 'Maven Dependencies' checkbox Click OK

    0 讨论(0)
  • 2020-12-23 09:38

    I have solved this issue by below steps:

    1. Right click the Maven Project -> Build Path -> Configure Build Path
    2. In Order and Export tab, you can see the message like '2 build path entries are missing'
    3. Now select 'JRE System Library' and 'Maven Dependencies' checkbox
    4. Click OK

    Now you can see below in all type of Explorers (Package or Project or Navigator)

    src/main/java
    
    src/main/resources
    
    src/test/java
    
    0 讨论(0)
  • 2020-12-23 09:40

    If none of the answers worked for you. You might be in the wrong "Window". I was in "Package explorer" and switching to "Project Explorer" showed me the folders.

    0 讨论(0)
  • 2020-12-23 09:41

    Eclipse filters out folders that are marked as source from the "raw" folder path. That is, they are visible only as source folders:

    example project

    If you can't see them in either place, then they

    • are either filtered out in the settings: check your settings for Package Explorer (the Package Explorer bar, downwards menu arrow -> Filters...)
    • or they were created externally and Eclipse haven't noticed them: Refresh your project in this case.
    • or they don't exist: right-click on the project, select New->Folder and input the path, e.g. src/test/java (not "Source Folder"). After you use Maven->Update Project... on the project, they will be automatically added as source folders, provided you have the default configuration.

    Now, as I said, those folder will only be used as source if you preserved the default configuration in your POM. If you defined other resources and/or testResources, those will be used instead. In general, Eclipse m2e synchronizes Eclipse's project source folder configuration with what's in your POM.

    EDIT: maybe this is unclear - see those folders at the top? The ones labeled with the /-separated paths? These are your folders. These are the same folders that you would expect to find in main and test, just represented differently.

    0 讨论(0)
  • 2020-12-23 09:42

    I was not able to see the build path option in the properties as well. Also the

    src/main/java

    was not visible in Project Explorer. below solution worked for me

    1. Go to Project root
    2. Select "Project facets" from Properties
    3. Check "Java"

    This fixes the issue

    0 讨论(0)
  • 2020-12-23 09:45

    If you are looking for Simple/quicker way, you can follow this solution.

    1. Right click on your project.
    2. Goto > Build Path > Configure Build Path > Java Build Path
    3. Goto 'Source' tab, there, you can see like <<your_project_name>>/src/main/java(missing).
    4. Click on it and remove.
    5. Click on Apply and Close.
    6. Now, right click on project and >New > Source folder > add source folder "src/main/java".

    happy learning and do not forget to upvote :)

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