Spring-Boot Maven project structure explained.

Tabrez Shaikh
4 min readOct 7, 2021

--

After creating a new Spring Boot project using Maven build tool, we are provided with a plethora of different files and folders. In this blog we will understand the purpose of these files and why they are necessary in making up the project and understand their importance when building an application.

Before we proceed further into the blog, let me make it clear that this blog is in continuation with my previous blog “Hello Web” where I gave detailed instructions on how to create your first spring boot web application. Feel free to check out the blog to get a better understanding of the project structure. With that said, this blog still stands independent without there being a need to go through the previous blog.

You can also take a look at the GitHub repository I created while making this project or even clone the repository using the git command given below to get complete understanding of what we’re trying to work upon.

$ git clone https://github.com/tabrezshaikh13/hello-web.git
Project structure in any typical spring boot web application

While learning to create our first spring boot web application in the previous blog, we ended up having the above shown project structure. Let us understand the purpose of these files one by one.

  1. The .mvn folder contains files like
    a. maven-wrapper.jar
    b. maven-wrapper.properties
    c. MavenWrapperDownloader.java
    These files help maven understand what type of packaging (JAR or WAR) is to be used the project and for projects that need a specific version of maven, we need not to install maven locally. Instead of installing many versions of maven, we can just use a project specific wrapper script that is provided when creating the spring boot project.
  2. The .settings folder will ensure that all users who check that project out into eclipse use the right project specific settings.
  3. The .src folder is the most important folder in any project since it contains all the source code and resources that makes up the application. It also contains several sub-folders namely main and test.
    a. The src/main/java folder as the name suggests is the most important part of any Maven project as it contains all the java code inside the java sub-folder.
    b. The src/main/resources folder contains all the resource files that are needed in order to run the application. Usually, it stores all the .css, .js and image files inside the static folder and all the .html and .jsp files inside the templates folder that are used to render the frontend.
    c. The test sub-folder holds all the test cases of the application that run when you build the project before publishing it.
  4. The application.properties file is used to tweak the default configurations in spring boot to have the application work the way you want. This is actually a way to customize your spring application and got nothing to do with spring boot.
  5. The target folder is the maven default output folder. When a project is built or packaged the final packaged file is generated in this folder with a .jar or .war extension that can be used to publish the web application.
  6. The pom.xml is an xml file that contains information about the project and configuration details used by maven to build the project. The POM (Project Object Model) file is the fundamental unit of work in maven. It contains information like the groupId and artifactId of the project, the version of the project, dependencies, plugins and resource information.

So this is how a typical spring boot maven project structure looks like and the above-mentioned points are their uses that help in building up the web application. If you like this blog and find it helpful, definitely stay tuned for the next one where I will be modifying the code base further and play around with it a little bit and see what features does spring boot provides us with.

Having said that, I bring my article to an end and bid you adieu. Hope this article helps you in ways I intend it to.
Support my work by giving a clap to this blog and share it ahead with people who you think might find it helpful. Do let me know in the comments down below if you liked my writing. I am open to constructive criticism and suggestions on how I can improve my blogs and articles so that it helps convey my message in a better way. Thank you.

--

--

Tabrez Shaikh

A Curious Senior Year Computer Engineering student who likes to enlighten the world by sharing knowledge, expertise and proficiencies.