Spring Boot and Core Spring Concepts

박진석·2025년 2월 3일
0
post-thumbnail

Spring Boot and Core Spring Concepts

Introduction to Spring

Development environments require attention to multiple aspects:

  • Server performance & stability
  • Security
  • Site logic
  • Business logic

Spring was created to allow developers to focus primarily on development by handling these complexities. Spring Boot further simplifies this by making Spring's complicated configurations easier to manage.

Spring vs Spring Boot

Key advantages of Spring Boot:
1. Automated Environment Configuration

  • Automatically configures Spring Core
  • Handles Spring MVC setup
  • Reduces boilerplate configuration
  1. Internal WAS (Web Application Server)
    • Only requires JAR file
    • No additional WAS settings needed
    • Embedded server configuration

Core Spring Concepts

1. Inversion of Control (IoC)

The Spring Container manages application components, handling:

  • Object creation
  • Object lifecycle
  • Dependency management

2. Dependency Injection (DI)

  • Spring creates and manages objects (Beans)
  • No need for manual object creation using 'new'
  • Uses @Autowired for dependency injection
  • @Component registers objects as Beans

3. Spring Beans

  • Java objects managed by Spring IoC Container
  • Lifecycle managed by Spring
  • Automatically handled dependencies
  • Configured through annotations

4. AOP (Aspect-Oriented Programming)

  • Separates cross-cutting concerns
  • Handles common functionalities:
    • Logging
    • Security
    • Transactions

5. PSA (Portable Service Abstraction)

  • Provides unified interfaces
  • Enables consistent API usage
  • Makes code portable across implementations

Spring Framework's Core Architecture

  1. IoC/DI (Infrastructure)

    • Establishes object dependencies
    • Creates loose coupling
    • Improves testability
  2. AOP (Services)

    • Separates business logic from auxiliary functions
    • Provides cross-cutting concern management
    • Enables clean separation of responsibilities
  3. PSA (Standardization)

    • Ensures consistent service usage
    • Enables implementation switching
    • Maintains code portability

Key Annotations

AnnotationPurpose
@ConfigurationRegisters configuration files
@RepositoryHandles ORM mapping
@Controller/@RestControllerManages routing
@ServiceImplements business logic
@ComponentRegisters as Bean

Note: All these annotations include @Component functionality, meaning they can be registered as Beans in the Spring container.

Architectural Analogy

Think of Spring's architecture like a well-organized city:

  • IoC/DI → City's infrastructure system
  • AOP → Specialized services across all areas
  • PSA → Standard interfaces for service providers

This organization allows developers to:

  • Focus on business logic
  • Write maintainable code
  • Easily switch implementations
  • Test applications effectively

0개의 댓글