Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 

I can access those folders as direct children of the project and they exist in the file system.

I'm using Spring Tool Suite (STS of Eclipse).

Maybe I can configure Eclipse somehow ?


enter image description hereenter image description hereenter image description here

like image 602
Sebastian Dusza Avatar asked Sep 13 '13 15:09

Sebastian Dusza


People also ask

Why is src not showing in Eclipse?

Note: In case if you do not see the src/main/java and src/test/java directories in your project structure then you will have to go to Project ->Properties ->Java BuildPath ->Libraries after that select JRE System Library and click on Edit and Select or configure correct JRE System Library click on Finish and then click ...

What is src main java in maven?

The src/main Directory As the name indicates, src/main is the most important directory of a Maven project. Anything that is supposed to be part of an artifact, be it a jar or war, should be present here. Its subdirectories are: src/main/java – Java source code for the artifact.

What is src folder in Eclipse?

src is where Java IDEs (at least Eclipse and NetBeans) put the source files, it is pretty much standard, and the hierarchy of the folder inside it has to match your Java packages names.


2 Answers

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 
like image 124
Ranjith Sekar Avatar answered Oct 03 '22 10:10

Ranjith Sekar


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.

like image 36
mikołak Avatar answered Oct 03 '22 10:10

mikołak