PrepZone Logo
PrepZone

Spring, IoC, and Why Boot Exists

The Spring ecosystem, inversion of control, and how Boot removes boilerplate.

Why this matters

  • "Spring" and "Spring Boot" are not interchangeable — interviews and job postings use both, and conflating them signals shallow knowledge.
  • The ecosystem has distinct projects (MVC, Data, Security) that Boot activates via starters; knowing the map helps you find documentation quickly.
  • Inversion of control is the architectural idea behind every @Autowired and @Bean in the BookStore API.
spring-boot-starter-web
spring-boot-starterCore Boot + logging
spring-webmvcControllers and REST
tomcat-embed-coreEmbedded server
jackson-databindJSON serialisation
spring-boot-starter-web pulls in Tomcat, Jackson, Spring MVC and more with tested versions.

The Spring portfolio

Projects you will touch in BookStore

  • Spring Framework — Core IoC container, AOP, transaction abstraction, and MVC web layer.
  • Spring Boot — Auto-configuration, embedded server, production-ready defaults, and the starter ecosystem.
  • Spring Data JPA — Repository abstraction over Hibernate for Book and Author entities.
  • Spring Security — Authentication, authorization, and the filter chain protecting /api/**.
  • Springdoc OpenAPI — Generates Swagger UI from your controller annotations.

Inversion of control explained

In a traditional BookStore app you might write:

Java
public class BookController {
    private final BookService bookService = new BookService(
        new JdbcBookRepository(new DataSource(...))
    );
}

Every class constructs its own dependencies. Changing the repository implementation means editing every caller.

Spring inverts this: the container creates objects and injects dependencies. You declare what you need; Spring figures out how to provide it.

Java
@RestController
public class BookController {
    private final BookService bookService;

    public BookController(BookService bookService) {
        this.bookService = bookService;  // injected by Spring
    }
}

The controller never calls new BookService(). The container does at startup.

ApplicationContext: the heart of Spring

The ApplicationContext is a registry of beans — objects Spring manages. At startup it:

Container startup steps

  1. Scans for @Component, @Service, @Repository, @Controller.
  2. Reads @Configuration classes and @Bean methods.
  3. Resolves constructor dependencies and creates instances.
  4. Applies @PostConstruct callbacks and registers shutdown hooks.

For BookStore, a single context holds one BookService, one BookRepository, and one DataSource — shared across all requests.

Why Boot exists

Plain Spring required extensive XML or Java configuration:

Java
@Configuration
public class WebConfig {
    @Bean
    public DispatcherServlet dispatcherServlet() { ... }
    @Bean
    public DataSource dataSource() { ... }
    // dozens more beans
}

Boot's auto-configuration detects classpath contents and configures beans conditionally. Add spring-boot-starter-data-jpa and a DataSource appears when application.yml has a spring.datasource.url.

Spring vs Spring Boot responsibilities

AspectSpring FrameworkSpring Boot
Dependency injectionYesUses Framework
MVC mappingYesAuto-registers DispatcherServlet
Embedded TomcatNoYes
Externalised configBasic supportapplication.yml, profiles, @ConfigurationProperties
Production metricsManual setupActuator starters
  • Dependency injection

    Spring FrameworkYes
    Spring BootUses Framework
  • MVC mapping

    Spring FrameworkYes
    Spring BootAuto-registers DispatcherServlet
  • Embedded Tomcat

    Spring FrameworkNo
    Spring BootYes
  • Externalised config

    Spring FrameworkBasic support
    Spring Bootapplication.yml, profiles, @ConfigurationProperties
  • Production metrics

    Spring FrameworkManual setup
    Spring BootActuator starters

Boot does not replace Spring — it configures it.

The starter pattern preview

Instead of listing twenty JAR coordinates, Boot offers curated bundles:

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

One dependency brings Tomcat, Jackson, Spring MVC, and validation. The starters module covers this in depth.

Jakarta EE namespace shift

Spring Boot 3.x runs on Jakarta EE 9+ packages (jakarta.servlet, jakarta.persistence). Code using javax.* imports from older tutorials will not compile. When reading Stack Overflow answers, check the Spring Boot version.

Ecosystem versioning

Spring Boot 3.4.x aligns with Spring Framework 6.x and requires Java 17+. The Spring release train publishes compatible versions together. Stick to the BOM — mixing manual version overrides causes subtle runtime failures.

Where BookStore fits

Your learning path builds the BookStore API layer by layer: web foundations → IoC wiring → Boot auto-config → REST endpoints → JPA persistence → cross-cutting concerns → security. Each module adds one Spring project to the same application.

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

That single annotation bootstraps the entire ecosystem for your app.

Quick recall

Everything you need if you only revisit this box.

  • Spring Framework provides IoC, MVC, AOP, and transactions; Boot auto-configures them.
  • Inversion of control means the container creates and wires objects — you declare dependencies, not construction.
  • ApplicationContext is the bean registry created at startup and shared across requests.
  • Boot 3.x uses Jakarta (jakarta.*) packages and requires Java 17+.
  • Starters bundle related dependencies; the BOM keeps versions compatible.
  • BookStore grows through the track by adding one Spring concern per module.

Test yourself

Answer these before moving on — recall is what makes it stick.