The default source folder for a Java Maven project is src/main/java. In the project on the right, the source folder is set to src via the following line in the pom.xml file:
<sourceDirectory>src</sourceDirectory>
If you remove the line or change the value, right-click the project and choose Maven > Update Project... to have Eclipse read the pom.xml file and update the source folder location accordingly.
How strictly should I follow the standard Maven project structure?
java - Location of generated source files for maven directory structure - Stack Overflow
Difference between src/main/java and src/test/java in a Maven project - Stack Overflow
How to edit the directory structure in Maven? - Stack Overflow
Videos
The default source folder for a Java Maven project is src/main/java. In the project on the right, the source folder is set to src via the following line in the pom.xml file:
<sourceDirectory>src</sourceDirectory>
If you remove the line or change the value, right-click the project and choose Maven > Update Project... to have Eclipse read the pom.xml file and update the source folder location accordingly.
Difference: Let's first understand the meaning of both the folders. In the left image src/main/java is the source folder which is used by eclipse to build the project. In the right image src is the source folder with the package main.java
Solution: It is not possible to edit your source folder So you have to copy your files and create a new source folder with name src/main/java.
Hi
I am learning Maven from the official docs. I see that it wants a src/main/java/com/mycompany/appname directory structure. So I did some googling on java packages and I see why these are useful. But my question is, is the java/com/ really necessary?
I really don't like all these nested folders. How about something like src/main/mycompany/appname? It's still a package right? However I am only a java novice so if there is a good reason for structuring it like this, I'd like to know.
I think the location depends on how the source is generated and handled.
The source code is generated automatically during the build process: Then i would use
target/main/java/,target/test/java/and so on. This code is not checked in into CVS since you can rebuild it fairly easy. In case you clean your project thetargetdirectory will be removed and the source will be rebuild.The source code is generated manually by an external tool or similar: I would use
generated/src/main/java/,generated/src/test/java/,generated/src/main/resources/and so on. This code should be checked in. A benefit is, as soon you see that the top-level directory name isgeneratedyou know that all files/directories below are also generated. Also you have the standard maven directory structure under the top-level directory. Another point is that clean-up is easy, just deletegeneratedand recreate it, without looking through many other directories (like in your example:src/main/generated-javaand src/test/generated-java).
EDIT: Another nice solution would be to create a maven project which only contains the generated source like myproject-generated-1.0.3.jar. This project would be a dependency in your real application. Then you would just put your generated source int src/main/java.
As much as i know there is no standard folder structure for generated sources. In my projects, i prefer src/gen/java kind of notation.
Maven and other build management environments (e.g. gradle) are based on the assumption that you do automated testing via e.g. unit tests. For that you need extra code for testing that should not be included in your final product delivered to your customer.
Thus, everything that goes into src/main/java is per default packaged into the product that you would deliver for your customer whereas everything that you put into src/test/java is not.
This is an advantage for various reasons:
- your delivered products are smaller
- it is easier to to find testrelated code inside your project
- you can load various libraries only for testing.
- ...
As per the Maven configurations, tests class will be found in the src/test directory and the source code will be found in the src/main directory. So src/main/java is the root directory for your source code & src/test/java/ is the root directory for your test code.
Ex: Hotel Package, Reservation class
Source Class file : src/main/java/Hotel/Reservation.java
Test Class file : src/test/java/Hotel/ReservationTest.java
To add a resource folder in eclipse:
Build Path
Configure Build Path
(or Properties -> Java Build Path)
Source Tab

Click on Add Folder

Create new Folder The same problem I also encountered while I was learning the spring boot wanted to add logback.xml in resources.
I am using sts for spring boot. As of my understanding, there are two things your file system folder structure and another sts folder structure.
First I created a folder in your file system at src/main/ and then add this folder into build path. *
For creating a folder follow below image 1,2 and 3
*



Now at the final step, add newly added resource folder into the build path. by clicking properties or directly build path button.
Click on source tab and then click on add folder and browse the resources folder and add that's all. See below image for more description and help.
