Video in progress
What is the Spring Framework and what problem does it solve?
Spring is a Java framework that creates your objects and wires them together for you (IoC/DI), and adds ready-made pieces on top: transactions, web, security and more.
📖 Answer
Without Spring, in a large application every class creates the objects it needs itself with new. Classes end up tightly glued to each other, and even swapping one piece in a test is painful.
Spring takes that job over: you put @Service or @Component on a class and it does the rest — creates it and hands it to whoever needs it.
@Service
public class OrderService {
private final PaymentClient payments;
public OrderService(PaymentClient payments) { // Spring passes this in
this.payments = payments;
}
}
Around that there are ready-made modules: Spring MVC (REST APIs), Spring Data (databases), Spring Security, transactions, caching. Spring Boot then brings all of this up with minimal configuration.
In one sentence for an interview: Spring is a container that manages dependencies, plus the ecosystem built around it.
Sign up to mark studied questions and save your progress.