C
Spring Boot/Intro/Lesson 03

Spring Boot Fundamentals — *Why Spring Boot?*

45 min·theory

Spring Boot Fundamentals — *Why Spring Boot?*

🎯 After reading this lesson

After completing this lesson, you will be able to confidently do the following three things:

  • ✅ Define Spring's three core principles (IoC · AOP · POJO) in one sentence
  • ✅ Distinguish the roles of @Component / @Service / @Repository / @Controller
  • ✅ Explain why Spring Boot put an end to the XML configuration hell of classic Spring

Keep these learning objectives as a checklist — close the lesson only once you can answer all of them.

What Is Spring — *Simplifying Complex Java Backends*

One-Line Summary

Spring = A framework that automatically handles repetitive, complex tasks when building servers in Java. Created in 2003 by Rod Johnson.

Why Spring Was Born

In the early 2000s, Java backends were built using a standard called EJB (Enterprise JavaBeans), which was notoriously complex. Even a simple feature required numerous configuration files, interfaces, and implementation classes. Developers complained that 'there is more configuration code than business logic.'

Spring stripped away that complexity, making it possible to build servers with plain Java objects (POJO). The paradigm in which the framework handles cross-cutting concerns like DI, AOP, and transactions spread explosively.

Spring vs Spring Boot — What Is the Difference?

Spring alone was far simpler than cumbersome EJB, but it still required a lot of configuration: dozens of XML configuration lines, installing an external Tomcat server, building and deploying WAR files...

Spring Boot (2014~) is an evolution that goes one step further with the philosophy of 'we handle configuration too.'

ItemSpring (Traditional)Spring Boot
ServerInstall external TomcatEmbedded Tomcat (run with java -jar)
ConfigurationManual XML/Java ConfigAuto-configuration (detects classpath)
DependenciesSpecify versions every timeStarter (one line: spring-boot-starter-web)
OperationsSeparate monitoring toolsActuator built-in (/actuator/health)
Startup5–10 minutes (configuration)30 seconds

Most developers use Spring Boot. When people say "Spring," they usually mean Spring Boot.

Why Spring Dominates in Korea

Over 80% of backend job listings in Korea require Spring. Kakao, Naver, Coupang, Toss, Daangn — all Spring-based. The reasons:

  • In the early 2010s, the e-Government Framework was standardized on Spring
  • Large enterprise SI companies built their systems with Spring
  • As a result, developers, resources, and education all became Spring-centric

For anyone aiming to become a backend developer in Korea, Spring is practically a requirement.

Auto-configuration — The Magic of Spring Boot

Add just the spring-boot-starter-web dependency and you get:

  • Embedded Tomcat started
  • DispatcherServlet registered
  • Jackson JSON serialization enabled
  • Static file serving (/static/ · /public/)
  • Default error page

All of this works with zero lines of code. Spring Boot looks at what is on the classpath and applies sensible defaults.

To change a setting, one line in application.properties or application.yml is enough:

yaml
server.port: 8080
spring.datasource.url: jdbc:postgresql://localhost/myapp
logging.level.root: INFO

Summary

  • Spring = Java backend framework (2003~)
  • Spring Boot = Spring + auto-configuration and embedded server (2014~)
  • 80%+ of Korean backend job listings are Spring-based
  • A production-ready server can be started in under 5 minutes

How to *Start* a Spring Boot Project

The Fastest Start — start.spring.io

https://start.spring.io — A project generator built by the Spring team. A working server in 5 minutes.

Options to choose:

  • Project: Gradle recommended (Maven is also OK)
  • Language: Java
  • Spring Boot Version: Latest stable release (3.x)
  • Dependencies: At minimum Spring Web (REST API). Common additions: Spring Data JPA, H2 Database, Lombok

Click GENERATE to download a zip file. Unzip it, open it in your IDE, and you are done.

Three Key Files

1. Main class — server entry point:

java
@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

The single @SpringBootApplication annotation does three things at once:

  • @Configuration — declares this class as a configuration class
  • @EnableAutoConfiguration — enables auto-configuration
  • @ComponentScan — automatically registers @Component, @Service, etc. in sub-packages

2. application.yml — configuration:

yaml
server:
  port: 8080

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/myapp
    username: admin
    password: ${DB_PASSWORD}      # from environment variable

  jpa:
    hibernate:
      ddl-auto: update             # for development; use validate in production
    show-sql: true

logging:
  level:
    root: INFO
    com.myapp: DEBUG               # DEBUG only for my own code

3. First controller:

java
@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello, Spring Boot!";
    }
}

Run ./gradlew bootRun → visit http://localhost:8080/hello → get the response 'Hello, Spring Boot!'

Directory Structure

code
src/main/java/com/myapp/
├── DemoApplication.java          # Main
├── controller/                    # HTTP handling
│   └── UserController.java
├── service/                       # Business logic
│   └── UserService.java
├── repository/                    # DB access
│   └── UserRepository.java
├── entity/                        # JPA entities
│   └── User.java
└── dto/                           # Request/response DTOs
    └── UserDto.java

src/main/resources/
├── application.yml
└── static/                        # Static files

src/test/java/                     # Tests

This is the standard Spring project structure — the first thing you will encounter at a company.

Common First-Time Mistakes

1. @SpringBootApplication placement: The main class must be in the top-level package. This is because it automatically scans @Components in sub-packages. If placed incorrectly, beans will not be registered.

2. Port conflict: If another process is already using port 8080, startup will fail. Change to server.port: 8081 or kill the existing process.

3. application.yml indentation: YAML is sensitive to 2-space indentation. Using tabs will cause errors. Stick to 2 spaces.

Summary

Download a zip from start.spring.io → open in IDE → add @RestController + @GetMapping → run bootRun → done. This is a flow achievable in under 5 minutes. Try it once and you will immediately feel the appeal of Spring Boot.

🤖 Try Asking an AI Like This

Once you understand the concepts in this lesson, you can give specific instructions to AI. Instead of a vague 'please fix this,' you make requests with vocabulary — that is the starting point for saving tokens.

  • 'Apply the Spring Boot Fundamentals — Why Spring Boot? pattern to this Spring Boot code'
  • 'Write a @SpringBootTest integration test related to Spring Boot Fundamentals — Why Spring Boot?'
  • 'Tell me 3 pitfalls to watch out for when using Spring Boot Fundamentals — Why Spring Boot? in real projects'

Why This Saves Tokens

When you do not know the concepts, you have to ask 'what is that?' after receiving an AI response. That follow-up question is what eats your tokens. Learn a concept once and the conversation ends in one go.

Spring Boot Basics — Why Spring Boot? - Spring Boot