1.
Spring vs Spring Boot: Spring is a framework providing comprehensive infrastructure support for
building Java applications, while Spring Boot is an extension of Spring that simplifies application
development with embedded servers, auto-configuration, and opinionated defaults.
2. Determining Active Profile: A Spring Boot application determines the active profile via the
spring.profiles.active property set in application.properties, application.yml, or passed as a JVM
argument (-Dspring.profiles.active=profileName).
3. Integrating Multiple Databases: Configure multiple DataSource beans with separate
configurations and use @Primary to define the default DataSource. Use EntityManagerFactory or
JpaTransactionManager for each database.
4. Filter vs Interceptor:
- Filter: Works at the servlet level and is used for request/response modification before reaching
the DispatcherServlet.
- Interceptor: Works at the Spring MVC level and is used for pre- and post-processing around
controller methods.
5. MVC Workflow:
- Frontend sends a request to the backend.
- DispatcherServlet routes the request to the appropriate Controller.
- Controller processes the request, interacts with services, and retrieves data.
- Data is returned to the frontend as a response.
6. Authorization vs Authentication:
- Authentication: Verifying user identity.
- Authorization: Determining access rights after authentication.
7. Connecting to a Database in Spring Boot: Define database properties in application.properties or
application.yml (e.g., URL, username, password). Spring Boot uses auto-configuration to connect
via DataSource.
8. Sessions in REST APIs: REST APIs are stateless by design, but sessions can be maintained
using mechanisms like tokens (JWT), cookies, or Spring Session.
9. Lombok: Lombok is a Java library that reduces boilerplate code by providing annotations like
@Getter, @Setter, @Data, etc.
10. DispatcherServlet: The DispatcherServlet is the front controller in Spring MVC that handles all
incoming requests and delegates them to appropriate handlers.
11. Spring Security and Spring Cloud:
- Spring Security: A framework for authentication, authorization, and securing web applications.
- Spring Cloud: Provides tools for building microservices, including service discovery,
configuration management, and API gateway.
12. IOC Container: The Inversion of Control (IOC) Container manages the lifecycle and
dependencies of Spring beans.
13. Dependency Injection and Types:
- Types: Constructor, Setter, Field Injection.
- Recommended: Constructor Injection (ensures immutability and mandatory dependencies).
14. @SpringBootApplication: Combines @Configuration, @EnableAutoConfiguration, and
@ComponentScan to bootstrap a Spring Boot application.
15. @Qualifier vs @Primary:
- @Primary: Sets the default bean if multiple beans are defined.
- @Qualifier: Explicitly specifies the bean to inject.
16. @RestController vs @Controller:
- @RestController: Combines @Controller and @ResponseBody, returning responses directly.
- @Controller: Used for web pages with view resolution.
17. @RequestParam vs @PathVariable:
- @RequestParam: Extracts query parameters.
- @PathVariable: Extracts variables from the URI path.
18. @Component vs @ComponentScan:
- @Component: Marks a class as a Spring-managed bean.
- @ComponentScan: Scans and registers components within specified packages.
19. @ExceptionHandler vs @ControllerAdvice:
- @ExceptionHandler: Handles exceptions in a specific controller.
- @ControllerAdvice: Provides global exception handling for all controllers.
20. Spring Boot Actuator: Provides production-ready features like monitoring and metrics for a
Spring Boot application.
21. Common HTTP Methods:
- GET: Retrieve data.
- POST: Create resources.
- PUT: Update resources.
- DELETE: Remove resources.