Printing and PDF export are disabled for this content. View it online at Full Stack Learning Simplified.
Spring Boot Project Structureπ± Beginner
A freshly generated Spring Boot project follows a highly predictable, standardized layout. This uniformity means an experienced Spring developer can jump into any project and instantly know where things belong.
What is the Layout?
Spring Boot projects are divided into src/main/java for logic and src/main/resources for configuration and static assets.
project
my-app/
ββ src/main/java/com/example/demo/
β ββ DemoApplication.java # The application entry point
β ββ controller/ # The web layer (handles HTTP requests)
β ββ service/ # The business logic layer
β ββ repository/ # The database access layer
ββ src/main/resources/
β ββ application.properties # Core configuration settings
β ββ static/ , templates/ # Static files and server-rendered views
ββ src/test/java/... # Unit and integration tests
ββ pom.xml # Maven build configuration
ββ mvnw # The Maven wrapper scriptHow the Entry Point Works
Every Spring Boot application starts from a class annotated with @SpringBootApplication. This class contains a standard Java main method that delegates to SpringApplication.run().
DemoApplication.java
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}Why is @SpringBootApplication Important?
This single annotation is a powerful shortcut that actually bundles three crucial configurations together:
@Configuration: Flags the class as a source of bean definitions.@EnableAutoConfiguration: Tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.@ComponentScan: Instructs Spring to look for other components, configurations, and services in the current package, allowing it to find the controllers.
Critical Warning: You must keep your main application class at the root package (e.g.,
com.example.demo). The component scanner only sweeps downward into sub-packages. Any classes placed in packages higher up or completely outside the root package will be ignored by Spring!Note: In the
resources folder, static/ is used to serve files directly (like CSS, JS, images), while templates/ is used for server-side templating engines (like Thymeleaf). If you are building a pure JSON REST API, you will likely leave both of these empty.Architecture Tip: As your application grows, consider organizing your packages by feature (e.g., a
user package containing its own controller, service, and repository) rather than by layer. This modular approach scales far better on massive enterprise applications.Free preview. Sign in and subscribe to unlock all 982 lessons across 31 courses.
Free preview Β· Β© 2026 Full Stack Learning Simplified