SPRING & SPRING BOOT COMPLETE NOTES
1. SPRING CORE (IOC & DI)
----------------------------
- IoC: Spring manages object creation & lifecycle.
- DI: Injects dependencies using @Autowired, constructor, or setter.
- Bean: A Spring-managed object using @Component, @Service, etc.
- ApplicationContext: Advanced Spring container.
2. IMPORTANT ANNOTATIONS
----------------------------
@Component - Generic Spring bean
@Controller - Web controller
@Service - Business logic
@Repository - Database interaction
@Autowired - Injects dependency
@Value - Injects property value
3. SPRING MVC (WEB)
----------------------------
- DispatcherServlet handles requests.
- Controller layer uses @Controller or @RestController.
- @GetMapping, @PostMapping to map URLs.
- Views: JSP, Thymeleaf, HTML.
4. SPRING SECURITY
----------------------------
- Authentication, Authorization.
- Use UserDetailsService, PasswordEncoder.
- Configure HTTP access and roles.
- JWT for stateless auth.
5. SPRING DATA JPA
----------------------------
- ORM using Hibernate + JPA.
- JpaRepository, CrudRepository for DB access.
- @Query for custom queries.
- @Entity for model classes.
6. TESTING
----------------------------
- @SpringBootTest: full context testing.
- @WebMvcTest: web layer only.
- @DataJpaTest: DB layer testing.
7. SPRING BOOT
----------------------------
- Auto-configures Spring.
- Uses embedded Tomcat.
- @SpringBootApplication: main app entry.
- application.properties for config.
8. REST APIs WITH SPRING BOOT
----------------------------
- @RestController for APIs.
- Use @RequestBody for POST, @PathVariable for dynamic URLs.
- ResponseEntity to customize response.
9. SPRING CLOUD
----------------------------
- Microservices framework.
- Eureka: service registry.
- Gateway: routes traffic.
- Feign: REST client.
- Config Server: centralized config.
10. ADVANCED TOPICS
----------------------------
- AOP: cross-cutting concerns like logging.
- CORS: cross-origin access.
- Scheduling: @Scheduled tasks.
- Validation: @Valid, @NotNull.
This document summarizes the essential concepts for mastering Spring & Spring Boot development.