When i create a new Maven project in Eclipse, directory structure contains both src/main/java
and src/main
(down below)
Question:
I understand my code should fall under src/main/java
, what is the purpose of the src/main
? Why does Eclipse create it?
Simple: Project is for more about embedded prgramming and java-project is for only with java-classes in package, you can place modules in source-folders but that's dirty work.
Maven project structure defines a folder in order to store all resources and files needed by a web application. Inside this folder you can put all the required files for a web application like jsp files, js files, html files, css files, template files, reports files, WEB-INF files (like web. xml), META-INF files, etc…
Many may give just a normal answer like “Maven has the ability to download dependencies automatically based on the dependencies block you put in respective maven project's pom. xml file”. Yes, that's true and its one of the major bonus point of maven based java project.
src/main/java
is Maven's standard layout for placement of your Java source codes.
Check http://java.sg/maven-standard-directory-layout/ for a list of standard Maven directories.
src/main/java Application/Library sources
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
LICENSE.txt Project's license
NOTICE.txt Notices and attributions required by libraries that the project depends on
README.txt Project's readme
For src/main/java to exist src/main/ must first exist so eclipse just shows you all the folders in your project including src/main/
If you want to remove them from your view in package explorer, you can create a filter for the package explorer view and exclude Non-Java elements.
Look for the down arrow in the top right of the package explorer view for the filters option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With