OOPS with Java – Unit V Notes
Unit–V Notes: Spring Framework & Spring Boot
1. Introduction to Spring Framework
Spring is an open-source Java framework used for developing enterprise applications.
Advantages: • Lightweight architecture
• Dependency Injection (DI)
• Inversion of Control (IoC)
• Easy testing and maintenance
2. Spring Core Basics
Spring Core provides: • IoC Container
• Dependency Injection
• Bean management
3. Dependency Injection (DI)
Dependency Injection means providing objects to a class instead of creating them inside the class.
Types of DI:
1. Constructor Injection
2. Setter Injection
4. Inversion of Control (IoC)
IoC transfers object creation control from programmer to Spring container.
5. Spring Bean
A Bean is an object managed by Spring container.
6. Bean Scopes
• Singleton – One object for entire application
• Prototype – New object every time
• Request – One object per HTTP request
• Session – One object per HTTP session
• Application – One object per web application
• WebSocket – One object per WebSocket
7. Spring AOP
AOP separates cross-cutting concerns like logging, security and transaction management.
8. Autowiring
Autowiring automatically injects dependencies.
9. Spring Annotations
• @Component
• @Autowired
• @Controller
• @Service
• @Repository
• @Configuration
• @Bean
10. Bean Lifecycle Callbacks
Lifecycle steps: 1. Bean creation
2. Dependency injection
3. Initialization
4. Ready to use
5. Destruction
11. Bean Configuration Styles
• XML Based Configuration
• Annotation Based Configuration
• Java Based Configuration
12. Introduction to Spring Boot
Spring Boot simplifies Spring application development using auto configuration and embedded servers.
13. Spring Boot Build Systems
• Maven
• Gradle
14. Spring Boot Code Structure
Contains: • controller
• service
• repository
• [Link]
15. Spring Boot Runner
[Link]() starts the application.
16. Logger in Spring Boot
Used for debugging and monitoring applications.
17. RESTful Web Services
REST APIs allow communication between client and server using HTTP methods.
18. Rest Controller
@RestController handles REST APIs.
19. Request Mapping
Maps HTTP requests to methods.
20. RequestBody
Used to receive JSON data from client.
21. Path Variable
Reads values directly from URL.
22. Request Parameter
Reads query parameters from URL.
23. HTTP Methods
• GET – Fetch data
• POST – Insert data
• PUT – Update data
• DELETE – Delete data
24. Building Web Applications
Steps: 1. Create project
2. Add dependencies
3. Create controller
4. Configure [Link]
5. Run application
Important Exam Questions
1. Explain Dependency Injection with types.
2. Explain Bean scopes in Spring.
3. Explain AOP in Spring Framework.
4. Explain Spring Boot architecture.
5. Explain RESTful Web Services.