Spring Framework Tutorial
Spring Framework Overview and Modules
Spring is an open-source application framework for Java. Its core idea is simple: instead of your classes creating and wiring their own dependencies, a container creates the objects, connects them, and manages their lifecycle for you. Everything else in the Spring ecosystem (web, data access, security, messaging, testing) is built on top of that container.
This lesson gives you the map. You will learn what problem Spring solves, how the framework is split into modules, how Spring Framework relates to Spring Boot and the other Spring projects, and which versions this course targets: Spring Framework 7.0 and Spring Boot 4.1.
What problem does Spring solve?
Enterprise Java in the early 2000s meant heavy application servers, verbose configuration, and code that was hard to test because every class built its own collaborators with the new keyword. Rod Johnson's book "Expert One-on-One J2EE Design and Development" (2002) argued for a lighter approach based on plain Java objects, and the code from that book grew into Spring.
Spring's answer is Inversion of Control: your objects declare what they need, and the container supplies it. This is called Dependency Injection. Because classes no longer create their dependencies, you can replace a real payment gateway with a fake one in a test without touching the class under test.
Spring also removes repetitive plumbing. Opening and closing JDBC connections, managing transactions, and translating checked exceptions are all handled by Spring so your code can focus on business logic.
The main modules
Spring Framework is not one big jar. It is a set of modules, and you add only what you need. The most important ones are:
- spring-core and spring-beans - the foundation: utilities, resource loading, and the bean factory that creates and wires objects.
- spring-context - the ApplicationContext, the richer container you use in almost every application. It adds events, internationalization, annotation-based configuration, and profiles.
- spring-expression - Spring Expression Language (SpEL), a small language for querying and setting values at runtime.
- spring-aop and spring-aspects - aspect-oriented programming for cross-cutting concerns such as logging, security checks, and transactions.
- spring-jdbc, spring-tx, spring-orm - data access: JdbcTemplate, declarative transactions, and integration with Hibernate and JPA.
- spring-web and spring-webmvc - the servlet-based web stack: controllers, REST endpoints, view rendering, and the REST client APIs.
- spring-webflux - the reactive web stack for non-blocking applications.
- spring-jms and spring-messaging - messaging support, including JMS.
- spring-test - the TestContext framework, MockMvc, and other testing helpers.
Spring Framework vs Spring Boot vs other projects
Beginners often confuse these, so be precise. Spring Framework is the core library described above. Spring Boot is a layer on top of it that removes setup work: it picks compatible dependency versions for you (starters), configures common beans automatically (auto-configuration), and embeds a web server so you can run your application with a single command.
Around them sits a family of projects: Spring Data (repositories), Spring Security (authentication and authorization), Spring Cloud (microservice patterns), Spring Batch, Spring Integration, and Spring AI. Most of them assume you are using Spring Boot.
The practical rule for this course: learn the Framework concepts first (containers, beans, AOP, transactions, MVC), because Boot only automates them. When something in a Boot application behaves strangely, the explanation is almost always a Framework concept.
Versions used in this course
Spring moves quickly, so it matters which version a tutorial is written for. This course targets the current generation:
- Spring Framework 7.0.x - the current reference documentation is for 7.0. It builds on the Java 17 baseline introduced in Spring 6 and continues the move to the Jakarta EE namespace (jakarta.* packages instead of javax.*).
- Spring Boot 4.1.x - the version start.spring.io offers by default. It requires Java 17 or newer and works with newer Java releases. Boot 4 also reorganised its starters and test modules, which later lessons point out.
- Java 17 minimum - we recommend installing an LTS release such as Java 21 or Java 25.
What is new in the Spring 7 generation
The current reference documentation lists several areas that beginners will meet: built-in resilience features (retry and concurrency limiting), stronger null-safety annotations, a unified REST client section covering RestClient, WebClient and HTTP service clients, RestTestClient for testing, and chapters on JVM AOT cache and checkpoint-restore for faster startup. Spring Boot 4 additionally adds properties for API versioning in MVC and WebFlux applications. Later lessons in this course cover each of these where they fit.
Example
The same idea with and without Spring: who creates the dependency?
// Without Spring: OrderService builds its own dependency (tight coupling)
class OrderService {
private final EmailSender sender = new SmtpEmailSender();
void placeOrder() {
sender.send("Order placed");
}
}
// With Spring: the container passes the dependency in (loose coupling)
@Service
class OrderService {
private final EmailSender sender;
OrderService(EmailSender sender) { // Spring injects a matching bean
this.sender = sender;
}
void placeOrder() {
sender.send("Order placed");
}
}
Common Mistakes
- Treating Spring Boot and Spring Framework as competitors. Boot is built on the Framework, it does not replace it.
- Following a tutorial written for Spring Boot 2 or 3 and copying package names (javax.*) or class names that no longer exist in current versions.
- Adding every Spring module "just in case". Add only the modules or starters your feature needs.
Key Points to Remember
- Spring is a container that creates, wires and manages your objects (IoC and dependency injection).
- The framework is modular: core, beans, context, AOP, JDBC/ORM, web, messaging, and test.
- Spring Boot adds starters, auto-configuration and an embedded server on top of Spring Framework.
- This course targets Spring Framework 7.0 and Spring Boot 4.1 on Java 17 or newer.
Practice the examples
Change an input, predict the result, then compare it with the output. Explain why the result changes.
Use your local JDK or project IDE for these examples. Codelab currently runs Python and HTML/CSS/JavaScript; framework examples may need project dependencies.