Hey everyone! π
This week marks the first milestone in my 5-month Java Full Stack learning journey. I focused on Spring Boot fundamentals and got hands-on with core concepts that every backend developer must know.
Hereβs what I explored, practiced, and learned (including a few beginner mistakes I ran into).
πΉ Spring Boot Modules & Layers
Spring Boot is modular, and understanding its architecture made everything much clearer:
Web Module β Helps in building web applications (Controllers, REST APIs).
Data Module β Handles database operations (JPA, repositories).
AOP Module β Aspect Oriented Programming (adding cross-cutting concerns like logging, security, transactions without touching core logic).
Core Module β Manages dependencies and the IoC container.
Test Module β Provides testing support for Spring components.
Beginner Tip: At first, I thought Spring Boot was just for APIs, but these modules show how it handles everything β from requests to DB to testing.
πΉDependency Management & IoC:
Instead of manually handling dependencies, Spring Boot uses IoC (Inversion of Control).
IoC Principle: Object creation & dependency management is shifted from developer to the Spring container.
Dependency Injection (DI): The actual implementation of IoC.
Two ways I tried dependency injection:
Constructor Injection β Cleaner, recommended, no need for @Autowired.
Field Injection β Needs @Autowired annotation.
@Service
public class UserService {
private final UserRepository userRepository;
// Constructor injection (preferred)
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
}
Beginner Mistake I made: At first, I kept adding new to create objects like we do in core Java. That broke the whole point of IoC! Instead, you should always let Spring handle object creation via DI.
πΉ Working with Beans
In Spring, Beans = Java Objects that the IoC container manages.
Instead of creating objects manually, you define them and let Spring inject them wherever needed.
This makes code loosely coupled and easier to test.
πΉAutowiring
I also learned about @Autowired in Spring Boot.
It tells Spring: βFind the right bean by type and inject it here.β
Super useful when connecting two classes (e.g., Controller β Service).
πΉ Spring XML Config
Before Spring Boot, you had to configure beans in XML files.
Example:
Thankfully, Spring Boot made life easier with annotations + auto-configuration. But itβs good to know the old way for interviews & fundamentals.
πΉ Servlet Dispatcher & REST APIs
I dug into the DispatcherServlet, the front controller in Spring.
It receives HTTP requests.
Delegates them to the correct controller.
Returns the response.
I also practiced building REST APIs using annotations like:
@RestController β Defines API endpoints.
@data, @AllArgsConstructor β From Lombok, helps reduce boilerplate.
πΉ Database Connection (Persistence Layer)
I connected Spring Boot with a database using JPA. Steps:
Added DB dependencies (e.g., MySQL).
Updated application.properties with DB credentials.
Used JPA repository for CRUD operations.
Example:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=pass
spring.jpa.hibernate.ddl-auto=update
Beginner Mistake I made: Forgot to add the correct driver dependency β application failed to start. Always double-check your pom.xml / build.gradle.
β Week 1 Takeaways
Understood Spring Bootβs layered modules (Web, Data, AOP, Core, Test).
Explored IoC, DI, Beans, and Autowiring.
Learned constructor vs field injection.
Understood the DispatcherServlet flow.
Built REST APIs with annotations.
Connected Spring Boot with DB using JPA.
Learned about XML config (old but gold).
π‘ Why Iβm Sharing This
Iβm documenting everything I learn publicly β the wins, the struggles, and the mistakes β so that beginners can learn faster and avoid my mistakes.
π Full code examples will be uploaded on my GitHub soon.
π Daily updates are on Twitter.
If youβre also learning Java Full Stack, letβs connect and grow together π
Top comments (0)