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
@Autowiredand@Beanin the BookStore API.
Spring vs Spring Boot
L1 · FresherSpring Framework provides IoC, MVC, Data, Security, and more. Spring Boot adds auto-configuration, starters, and embedded servers so BookStore boots with minimal XML or Java config.
Inversion of control in one sentence
L2 · IntermediateYou declare components; the container creates them and injects dependencies. Boot's @SpringBootApplication enables component scan and auto-config on the classpath.
Spring projects you still touch in Boot
L3 · AdvancedSpring Data JPA, Spring Security, and Spring MVC are libraries inside Boot — not separate servers. Knowing which layer owns a bug (MVC vs Data vs Security) speeds up fixes.
When plain Spring still wins
L4 · ExpertNon-Boot deployments on external Tomcat, heavy XML legacy, or custom classloader environments may skip Boot. Interview answer: Boot optimizes the default path; Spring remains the core programming model.
Arrows show @Autowired wiring — container injects at startup
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:
public class BookController {
private final BookService bookService = new BookService(
new JdbcBookRepository(new DataSource(/* url, credentials */))
);
}
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.
// learn:fragment
@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
- Scans for
@Component,@Service,@Repository,@Controller. - Reads
@Configurationclasses and@Beanmethods. - Resolves constructor dependencies and creates instances.
- Applies
@PostConstructcallbacks and registers shutdown hooks.
For BookStore, a single context holds one BookService, one BookRepository, and one DataSource — shared across all requests.
Advantages and disadvantages
| Advantages | What you gain in BookStore | Disadvantages | What it costs |
|---|---|---|---|
| Auto-configuration | DataSource, Jackson, and Tomcat appear because the starter is on the classpath | Hidden behaviour | A bean exists that you did not write, and the condition that created it is easy to miss |
| Starters and the BOM | One dependency, versions that work together | Opinionated stack | Replacing Tomcat or the JSON library means excluding transitive modules |
| Embedded server | `java -jar` is the whole deploy | Fat JAR | Larger images and a server you configure with properties instead of server.xml |
| Production defaults | Actuator, externalised config, sensible error pages | Startup and memory | Component scan and auto-config do more work than a hand-built context |
| Fast path to a feature | A CRUD API in one module | Magic during outages | You still need to know the filter chain, proxies, and property order when defaults are wrong |
Auto-configuration
What you gain in BookStoreDataSource, Jackson, and Tomcat appear because the starter is on the classpathDisadvantagesHidden behaviourWhat it costsA bean exists that you did not write, and the condition that created it is easy to missStarters and the BOM
What you gain in BookStoreOne dependency, versions that work togetherDisadvantagesOpinionated stackWhat it costsReplacing Tomcat or the JSON library means excluding transitive modulesEmbedded server
What you gain in BookStore`java -jar` is the whole deployDisadvantagesFat JARWhat it costsLarger images and a server you configure with properties instead of server.xmlProduction defaults
What you gain in BookStoreActuator, externalised config, sensible error pagesDisadvantagesStartup and memoryWhat it costsComponent scan and auto-config do more work than a hand-built contextFast path to a feature
What you gain in BookStoreA CRUD API in one moduleDisadvantagesMagic during outagesWhat it costsYou still need to know the filter chain, proxies, and property order when defaults are wrong
Boot is the right default for a new BookStore service. It is a poor fit when you must deploy a WAR onto an application server the platform team already runs, or when a tiny library should not start an embedded container. In those cases use Spring Framework without the Boot launcher.
Why Boot exists
Plain Spring required extensive XML or Java configuration:
// learn:fragment
@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
| Aspect | Spring Framework | Spring Boot |
|---|---|---|
| Dependency injection | Yes | Uses Framework |
| MVC mapping | Yes | Auto-registers DispatcherServlet |
| Embedded Tomcat | No | Yes |
| Externalised config | Basic support | application.yml, profiles, @ConfigurationProperties |
| Production metrics | Manual setup | Actuator starters |
Dependency injection
Spring FrameworkYesSpring BootUses FrameworkMVC mapping
Spring FrameworkYesSpring BootAuto-registers DispatcherServletEmbedded Tomcat
Spring FrameworkNoSpring BootYesExternalised config
Spring FrameworkBasic supportSpring Bootapplication.yml, profiles, @ConfigurationPropertiesProduction metrics
Spring FrameworkManual setupSpring BootActuator starters
Boot does not replace Spring — it configures it.
The starter pattern preview
Instead of listing twenty JAR coordinates, Boot offers curated bundles:
<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.5.x aligns with Spring Framework 6.x and requires Java 21+. 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.
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.
ApplicationContextis the bean registry created at startup and shared across requests.- Boot 3.x uses Jakarta (
jakarta.*) packages and requires Java 21+. - Boot's advantages are auto-configuration, starters, an embedded server, and production defaults.
- The cost is hidden beans, a fatter deployable, and defaults you must know how to override.
- 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.