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

前端 未结 16 2065
情深已故
情深已故 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: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.

提交回复
热议问题