Chapter 1: Spring in the real world
Introduces Spring as a widely used Java/JVM application framework and explains that the book’s Java examples teach concepts applicable in other JVM languages.
After this chapter you will be able to
- Spring’s role and uses. Describe Spring as an application framework for the Java/JVM ecosystem and give examples of the kinds of applications built with it.
- Framework foundation and feature selection. Explain that a framework provides a pre-built, opinionated foundation for application-specific code, and that developers select and assemble the features their application needs rather than use everything it offers.
- Business logic and reusable plumbing. Explain why applications with different user-facing purposes can reuse common functionality, and how that reuse saves work and can benefit from prior testing and a developer community.
- Spring ecosystem and core capabilities. Describe Spring as an ecosystem rather than a single framework, and identify the broad roles of Spring Core, Spring MVC, and Spring Testing.
- Inversion of control and context. Explain what control is inverted in Spring and how the IoC container, also called the Spring context, lets Spring manage application objects.
- Two Spring persistence offerings. Distinguish Spring Data Access from the separate Spring Data project and describe their respective roles in persistence.
- Spring Boot default configuration. Explain Spring Boot's convention-over-configuration idea and why it generally reduces configuration code.
- Spring beyond backend applications. Explain that Spring is often used for backend applications but can also be useful for automation testing and standalone desktop applications, without assuming it is a good fit in every case.
- Backend application responsibilities. Describe how a backend application serves client requests and manages data, including its possible use of databases and communication with other backend applications.
- Spring for complex backends. Explain why Spring is a common fit for backend applications, using the section’s examples of integration with other apps and database persistence.
- Automated testing app workflow. Explain why teams automate end-to-end tests and how a testing app provides feedback as the system changes.
- Spring support for testing apps. Describe ways Spring can help an automation test app alongside frameworks used to write test scenarios.
- Desktop object instance management. Explain how a desktop application can use the Spring IoC container and why the section recommends it.
- Framework fit warning signs. Explain why a framework should not be used automatically, and describe the four situations this section gives for considering an alternative.
- Container footprint and startup. Explain why application size matters when deploying in containers: containers should be quick to destroy and recreate, and a smaller app can initialize faster.
- Serverless framework tradeoff. Justify why a small serverless function may be better off without a framework, while distinguishing that case from a rule against frameworks in all containerized apps.
- Security-driven framework restrictions. Explain why some security-sensitive projects may avoid an open-source framework and rebuild functionality themselves, without treating this as a rule for all government apps.
- Framework customization trade-off. Explain why a framework may be impractical when adapting its components requires more code than building the functionality without it, and state what to consider instead.
- Benefits of framework replacement. Explain how to decide whether to replace working application architecture with a framework: identify a concrete benefit, such as better maintainability, performance, or security, and weigh it against cost and uncertainty.
Section by section
Introduction
Introduces Spring as a widely used Java/JVM application framework and explains that the book’s Java examples teach concepts applicable in other JVM languages.
- Spring’s role and uses: Describe Spring as an application framework for the Java/JVM ecosystem and give examples of the kinds of applications built with it.
Why it matters: This gives you a starting point for recognizing what Spring is and where it can be used. - Java examples and language portability: Explain why the book uses Java examples even though the Spring knowledge it teaches can be applied with another JVM language.
Why it matters: You need not treat the book’s choice of Java as a limit on where its Spring concepts apply.
Key terms: Spring framework, application framework, Java/JVM ecosystem, Java examples, JVM language, Kotlin
1.1 Why should we use frameworks?
This section explains what an application framework provides and why reusing its structure and common functionality can be more effective than building everything from scratch.
- Framework foundation and feature selection: Explain that a framework provides a pre-built, opinionated foundation for application-specific code, and that developers select and assemble the features their application needs rather than use everything it offers.
Why it matters: This explains both the head start a framework gives you and why using one still requires judgment. - Framework and library distinction: Distinguish a library that application code calls for a task from a framework that organizes the application and often controls how it runs and calls application code.
Why it matters: The distinction clarifies why adopting a framework affects an application’s structure, not just its available tools. - Business logic and reusable plumbing: Explain why applications with different user-facing purposes can reuse common functionality, and how that reuse saves work and can benefit from prior testing and a developer community.
Why it matters: It explains the practical value of frameworks even when two applications do very different things for their users.
Key terms: framework, opinionated architecture, predefined structure, library, business logic code, use case, plumbing, reuse
1.2 The Spring ecosystem
This section maps the main parts of the Spring ecosystem and explains, at a high level, how Spring manages application code and how several of its projects serve different needs.
- Spring ecosystem and core capabilities: Describe Spring as an ecosystem rather than a single framework, and identify the broad roles of Spring Core, Spring MVC, and Spring Testing.
Why it matters: This map helps you place a Spring feature in the part of the ecosystem that serves its purpose. - Inversion of control and context: Explain what control is inverted in Spring and how the IoC container, also called the Spring context, lets Spring manage application objects.
Why it matters: The context is the starting point for understanding why Spring can manage objects in your app. - Spring method interception: Describe, at a high level, how Spring can augment methods of instances it controls.
Why it matters: It gives a concrete example of what Spring's control over an app can enable. - Two Spring persistence offerings: Distinguish Spring Data Access from the separate Spring Data project and describe their respective roles in persistence.
Why it matters: The similar names refer to different parts of Spring, so distinguishing them makes later persistence topics easier to follow. - Spring Boot default configuration: Explain Spring Boot's convention-over-configuration idea and why it generally reduces configuration code.
Why it matters: This explains the basic appeal of Spring Boot before the book turns to using it. - Component alternatives and tradeoffs: Explain why alternatives to Spring are best considered for individual components or projects rather than for the entire ecosystem, and why a choice depends on the scenario.
Why it matters: It encourages choosing a tool for the particular problem rather than treating Spring as the only possible answer.
Key terms: Spring ecosystem, Spring Core, Spring MVC, Spring Testing, inversion of control (IoC), IoC container, Spring context, configuration, aspects, aspecting the method
1.3 Spring in real-world scenarios
Introduces the range of applications in which Spring can be useful while cautioning that a framework is not always the right choice.
- Spring beyond backend applications: Explain that Spring is often used for backend applications but can also be useful for automation testing and standalone desktop applications, without assuming it is a good fit in every case.
Why it matters: This keeps you from equating Spring with backend web development or assuming it fits every project.
Key terms: Spring framework, backend applications, automation testing app, standalone desktop scenarios
1.3.1 Using Spring in the development of a backend app
This section describes what a backend application does and why Spring is commonly used to build one.
- Backend application responsibilities: Describe how a backend application serves client requests and manages data, including its possible use of databases and communication with other backend applications.
Why it matters: This gives you a picture of the kind of application the book mainly uses to explain Spring. - Spring for complex backends: Explain why Spring is a common fit for backend applications, using the section’s examples of integration with other apps and database persistence.
Why it matters: It explains why Spring is useful for the real-world backend scenarios emphasized in the book.
Key terms: backend application, client apps, server side, database, Spring ecosystem, backend applications, integration, persistence
1.3.2 Using Spring in an automation test app
The section explains why teams build and regularly run automation test apps, and how Spring can support those apps alongside testing frameworks.
- Automated testing app workflow: Explain why teams automate end-to-end tests and how a testing app provides feedback as the system changes.
Why it matters: Regular automated checks help developers catch broken existing behavior soon after a change. - Spring support for testing apps: Describe ways Spring can help an automation test app alongside frameworks used to write test scenarios.
Why it matters: A testing app can use Spring for supporting application needs even when another framework defines its test scenarios.
Key terms: automation testing, end-to-end testing, testing app, integration tool, Spring IoC container, Spring Data, test scenarios
1.3.3 Using Spring for the development of a desktop app
The section explains how Spring components can help build maintainable desktop applications and provide features beyond object management.
- Desktop object instance management: Explain how a desktop application can use the Spring IoC container and why the section recommends it.
Why it matters: Spring’s object management can be useful even when the application is not a web app. - Additional desktop app features: Describe the other kinds of desktop-app features for which the section suggests Spring tools.
Why it matters: Spring may help with several practical features of a desktop app, not just its object instances.
Key terms: Spring IoC container, object instances, maintainability, backend, web services, remote calls, caching solution
1.4 When not to use frameworks
This section explains that frameworks are not always a good fit and identifies four situations in which to consider avoiding one.
- Framework fit warning signs: Explain why a framework should not be used automatically, and describe the four situations this section gives for considering an alternative.
Why it matters: Choosing a framework should depend on whether it helps with the actual job rather than adding unnecessary cost.
Key terms: framework, footprint, custom code, customizations
1.4.1 You need to have a small footprint
Explains why a small application footprint can be a reason to avoid a framework, especially for serverless functions.
- Container footprint and startup: Explain why application size matters when deploying in containers: containers should be quick to destroy and recreate, and a smaller app can initialize faster.
Why it matters: Footprint can affect how quickly a containerized app is ready to run. - Serverless framework tradeoff: Justify why a small serverless function may be better off without a framework, while distinguishing that case from a rule against frameworks in all containerized apps.
Why it matters: It gives you a specific case where a framework’s added dependencies may not be worth their cost.
Key terms: containers, footprint, initialization, serverless function, framework, dependencies
1.4.2 Security needs dictate custom code
This section explains why unusually strict security requirements can lead some projects to use custom code instead of a framework.
- Security-driven framework restrictions: Explain why some security-sensitive projects may avoid an open-source framework and rebuild functionality themselves, without treating this as a rule for all government apps.
Why it matters: It shows why a project's security requirements can outweigh the convenience of a framework. - Open-source security tradeoff: Distinguish the usual security and cost benefits of an open-source framework from the exceptional decision to invest in custom code.
Why it matters: The choice is a tradeoff, not a claim that custom code is normally safer or cheaper.
Key terms: open-source framework, vulnerability, third-party source, stakeholders
1.4.3 Abundant existing customizations make a framework impractical
This section explains when extensive customization can make a framework a worse choice than writing the functionality without one.
- Framework customization trade-off: Explain why a framework may be impractical when adapting its components requires more code than building the functionality without it, and state what to consider instead.
Why it matters: A framework should save effort overall, not create more adaptation work than the alternative.
Key terms: framework, components, customize
1.4.4 You won’t benefit from switching to a framework
This section argues that replacing working code with a popular framework is worthwhile only when the expected benefits justify the cost and risk, using a database-code migration as an example.
- Benefits of framework replacement: Explain how to decide whether to replace working application architecture with a framework: identify a concrete benefit, such as better maintainability, performance, or security, and weigh it against cost and uncertainty.
Why it matters: This helps you judge a framework change by its value to the application, not by its popularity. - Database code migration choice: Describe why the team abandoned its proposed Hibernate migration and used JdbcTemplate instead to improve the application's direct JDBC code.
Why it matters: The example shows how a smaller change can solve the actual problem without taking on an unnecessary migration.
Key terms: framework, maintainable, performant, secure, JDBC, Hibernate, JdbcTemplate, proof of concept
1.5 What will you learn in this book
This section identifies the book’s intended audience and previews the Spring topics it will cover.
1.6 Questions
This section lists questions for readers to check their understanding of chapter 1; it does not explain the answers.
1.7 Summary
This summary recaps why frameworks are useful, how to evaluate one, and the breadth of the Spring ecosystem.
Where this is used later
- Implementing a web app with Spring MVC (chapter 7) · Spring MVC is used to implement a web app.
- Implementing unit tests in Spring apps (chapter 15) · Spring tools are used to implement unit tests.
- Using the @Bean annotation to create beans (chapter 2) · Objects are made known to the Spring context as beans.
- How aspects work in Spring (chapter 6) · The high-level idea of method interception precedes the explanation of how aspects work.
- Using JdbcTemplate to work with persisted data (chapter 12) · JDBC-based persistence uses the fundamental data-access tools.
- What Spring Data is (chapter 14) · Spring Data is introduced as its own project.
- Using autoconfiguration by convention based on dependencies (chapter 7) · Autoconfiguration develops the idea of configuration based on conventions.
- A general overview of a web app (chapter 7) · Provides the server-and-client distinction used when discussing web apps.
Concepts explained in this chapter
- frameworkA software framework is a reusable foundation of components, conventions, and extension points for developing software.
- SpringSpring Framework is an open-source Java framework for building enterprise and web applications.
- Spring IoC containerThe Spring IoC container creates, configures, and manages Spring application objects and their dependencies.
- Spring DataSpring Data is a family of Spring projects that simplifies access to data stores through consistent repository-based abstractions.
- Spring ecosystemThe Spring ecosystem is the collection of Spring frameworks and related projects that support application development.
- convention over configurationConvention over configuration is a software design approach in which standard conventions supply defaults and explicit configuration is needed only for deviations.
- spring-contextThe spring-context module is a Spring Framework module that provides the application context and related infrastructure.
- Spring BootSpring Boot is a Spring ecosystem project that provides convention-based default configuration for Spring applications.
- Spring CoreThe foundational Spring project that provides the core container and dependency-injection infrastructure for Spring applications.
- business logicBusiness logic comprises the domain-specific rules and processes governing an application's core operations.
- inversion of controlInversion of control is a design principle in which a framework or container takes responsibility for coordinating application components instead of the components controlling that coordination themselves.
- Spring Data AccessSpring Data Access is a Spring Core module providing foundational database access, JDBC, and transaction capabilities.
- Spring MVCSpring MVC is the Spring web framework for developing applications that handle HTTP requests.
- JdbcTemplateJdbcTemplate is a Spring API component that simplifies JDBC database access by handling recurring connection, statement, and result-processing code.
- object-relational mapperAn ORM framework provides software for mapping application objects to relational database records and relationships.
- databaseA database is an organized collection of data stored for retrieval and management.
- backendThe execution environment where backend software runs and processes client requests.
- interceptorAn aspect is a modular unit in aspect-oriented programming that intercepts selected program operations and applies cross-cutting behavior.
- rest apiA network-accessible service that exposes resources and operations according to REST constraints.
- data layerA persistence layer is a software layer responsible for storing and retrieving application data beyond the lifetime of a process.
- persistencePersistence is the retention of application data beyond the lifetime of the process that created it.
- web applicationA web application is software accessed through web technologies, typically using a browser as its client interface.
- software testingThe systematic evaluation of software behavior against expected requirements or outcomes.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
