Spring Boot Project Structure Explained

Hey guys in this article, you will learn about Spring boot project structure from start to end with details explanation.

Read More:

Create spring boot project

There are many different ways to create a spring boot application, you can follow the below articles to create one –

>> Create spring boot application using Spring initializer
>> Create spring boot application in Spring tool suite [STS]
>> Create spring boot application in IntelliJ IDEA

Project Structure

If you create a spring boot project either using STS IDE or Spring Initializr, it follows the standard maven project sturcture

It creates so many files and folders. Let’s discuss these one by one in detail

  • src/main/java: Contains the java source code. It contains the base package by default. The base package contains the base class with main() method.
  • in.bushansirgur.springbootapp: This is the base package which is created by spring initializer. The package name is given at the time creating the project.
  • SpringbootappApplication.java: This is the base class, which contains the main() method with @SpringBootApplication annotation. This is the starting point to our spring boot application.
package in.bushansirgur.springbootapp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringbootappApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootappApplication.class, args);

  • src/main/resources: It contains static folder, templates folder and property file.
  • static: This folder contains the static files such as html, javascript, css files. If we are creating the spring boot web application then this folder may contain the static files.
  • templates: This folder contains the templates for our application. For example, if we are creating web application, if we use thymeleaf template engine then this folder contains all the UI templates.
  • src/test/java: It contains the java source files for Unit testing. This also contains the base package and base class for Unit testing.
  • JRE System library: This contains the JDK and JRE system related jars.
  • Maven Dependencies: This contains the dependency jars for our application.
  • src: This folder is same as the src/main/java
  • target: This folder contains the war/jar and build related files after the application is successfully build.
  • HELP.md: This file contains the reference links for spring boot and apache tomcat
  • mvnw: These are the Maven wrapper files, which allows us to run the maven project on Linux/mac
  • mvnw.cmd: This is also Maven wrapper files, which allows us to run the maven project on Windows platform
  • pom.xml: It contains the project related information and dependencies used in the application.

That’s it for this post, if you like this post, share this with your friends and colleagues or you can share this within your social media platform. Thanks, I will see you in our next post.

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply