Skillversitas

Project Structure

Maven Folder Structure

When you create a Spring Boot project with Maven, this is the structure it generates:

my-app/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/example/demo/
│   │   │       └── DemoApplication.java
│   │   └── resources/
│   │       ├── application.properties
│   │       ├── static/
│   │       └── templates/
│   └── test/
│       └── java/
│           └── com/example/demo/
│               └── DemoApplicationTests.java
├── pom.xml
└── mvnw / mvnw.cmd

What Each Folder Is For

Folder/File Purpose
src/main/java Main source code
src/main/resources Configuration files & static assets
src/test/java Unit tests
pom.xml Maven configuration & dependencies
mvnw Maven Wrapper — no need to install Maven globally

Package Naming

Package naming conventions use reverse domain names:

com.example.demo
├── controller/    → REST endpoints
├── service/       → Business logic
├── repository/    → Database access
├── model/         → Entity / domain object
├── dto/           → Data Transfer Object
└── config/        → Additional configuration

pom.xml

The pom.xml file is the heart of Maven configuration:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.2.0</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

spring-boot-starter-parent provides default configuration for the compiler, encoding, and dependency management.

@SpringBootApplication

This annotation is a combination of three annotations:

@SpringBootApplication  // Combination of:
                       // 1. @SpringBootConfiguration
                       // 2. @EnableAutoConfiguration
                       // 3. @ComponentScan("com.example.demo")
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
Annotation Purpose
@SpringBootConfiguration Marks a class as configuration
@EnableAutoConfiguration Enables auto-configuration
@ComponentScan Scans packages for Spring components

Auto-Configuration

Spring Boot reads the dependencies in pom.xml and then automatically configures the appropriate components. Example: the spring-boot-starter-data-jpa dependency → automatically configures the DataSource, EntityManagerFactory, and TransactionManager.

The Application.java Main Class

The DemoApplication class is the entry point. The main() method calls SpringApplication.run(), which starts the IoC container and the embedded server.

Spring Boot automatically scans the packages under the @SpringBootApplication class. That's why the main class belongs in the root package — it acts as the root for the package scanner.

Understood the project structure? In the next chapter, we'll learn how to configure the application using application.properties.