Project Folder Structure — Spring Technical Interview Questions & Answers

src/main/java, src/main/resources and test conventions.

Project Folder Structure

  • Boot follows a standard Maven/Gradle folder layout.
  • src/main/java: Your application code (main class near the root package).
  • src/main/resources: application.properties, static files, templates.
  • src/test/java: Tests.
  • Keep the main class in a parent package so @ComponentScan finds your beans.
  • Putting the main class in a weird package that misses component scan.
  • Main class package should be above your controllers/services.

Technical Interview Tip: Explain why main class package location matters for scanning.

Code Examples for Project Folder Structure

Project Folder Structure — working example

// Typical layout after Initializr (Maven):
// src/main/java/.../DemoApplication.java
// src/main/resources/application.properties
// pom.xml → spring-boot-starter-web

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class BootHooks {
  @Bean
  CommandLineRunner seed() {
    return args -> System.out.println("app ready: " + String.join(",", args));
  }
}

Project Folder Structure — create projects via Initializr/STS; run the @SpringBootApplication main class or package an executable jar.

How to Explain Project Folder Structure to an Interviewer

What is Project Folder Structure (sb)?

Used for a short Project Folder Structure sb example a small REST app Not just the heading

Give one small example of Project Folder Structure (sb).

the smallest Project Folder Structure sb example you can type src/main/java, src/main/resources and test conventions

What mistake do beginners make with Project Folder Structure (sb)?

only saying “Project Folder Structure sb” with no example Show the fix

Where do you use Project Folder Structure (sb)?

a small REST app a short Project Folder Structure sb example