liveBook · Manning

Spring

As explained in Spring in Action, Sixth Edition

An open-source Java application framework that provides infrastructure for building applications through containers, dependency injection, web support, data access, security, integration, and related capabilities.

Spring is a Java application framework for building applications from cooperating components. Its core is a container called the Spring application context. The context creates and manages components, called beans, and connects them so they can work together. section 1.1

Those connections use dependency injection. Instead of having one component create another component it needs, the container supplies the dependency, often through a constructor. For example, a product service can receive an inventory service so it can include inventory levels in product information. section 1.1

@Configuration
public class ServiceConfiguration {
  @Bean
  public InventoryService inventoryService() {
    return new InventoryService();
  }
 
  @Bean
  public ProductService productService() {
    return new ProductService(inventoryService());
  }
}

This Java configuration declares both services as beans and passes the inventory service to the product service. It makes the container’s wiring visible in a small example. section 1.1

Spring offers more than its container. The core framework includes Spring MVC for web requests and REST APIs, JdbcTemplate for JDBC-based data access, and Spring WebFlux for reactive web applications. Related libraries add options for security, integration, monitoring, and microservices. section 1.4.1 section 1.1

Spring Boot makes a small Spring web application quicker to start:

  • Create a project with Spring Initializr, then write a controller, a view template, and a test for a home page. section 1.3.6
  • Add Web and Thymeleaf starters to pom.xml. Their dependencies bring in Spring MVC, embedded Tomcat, and Thymeleaf. section 1.3.6
  • At startup, Spring Boot autoconfiguration detects those libraries and configures supporting beans. Application code can stay focused on the home page rather than most framework setup. section 1.3.6

Beans can also be declared explicitly with Java or XML, or found through component scanning. Spring Boot adds automatic configuration and simplified dependency management; it builds on Spring rather than replacing it. section 1.5

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains containers and dependency injection with services, then traces a small web application through starters and autoconfiguration; defers detailed REST and reactive work.
Examples
Uses product and inventory services for bean wiring and a home page controller, template, and test for web development.
What it assumes
Assumes basic Java project and class familiarity while introducing the application context, beans, and dependency injection from first principles.
What you can do after
Apply it via Spring Initializr and Spring Boot to create and test a simple web application.
How it connects
Links dependency injection and application contexts to Spring Boot, Spring MVC, data persistence, and reactive programming.

Also explained in

Compare how 3 books explain Spring →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.