This repository contains my daily Spring learning and revision progress, covering key concepts and practical implementations. Below is a summary of the topics I have covered so far.
- Definition: Beans are objects that are managed by the Spring IoC container.
- Bean Scopes:
singleton(Default): A single instance per Spring IoC container.prototype: A new instance for every request.request,session,application: Web-specific scopes.
- Bean Lifecycle:
- Initialization and destruction callbacks using
@PostConstructand@PreDestroyannotations or implementingInitializingBeanandDisposableBeaninterfaces.
- Initialization and destruction callbacks using
- Configuration:
- XML-based configuration (
<bean>tags). - Java-based configuration (
@Configuration,@Beanannotations). - Annotation-based (
@Component,@Service,@Repository).
- XML-based configuration (
- Types of Autowiring:
@Autowired: Automatically injects a dependency by type.@Qualifier: Used with@Autowiredto resolve ambiguity when multiple beans of the same type exist.@Primary: Marks a bean as the default when multiple candidates exist.
- Handling Conflicts:
- Resolving multiple beans of the same type using
@Qualifier. - Circular dependencies:
- Setter injection or
@Lazyinitialization to break dependency cycles. - Proper design to avoid tightly coupled dependencies.
- Setter injection or
- Resolving multiple beans of the same type using
- Definition: AOP is used to modularize cross-cutting concerns like logging, security, and transaction management.
- Key Concepts:
- Aspect: A module encapsulating cross-cutting concerns.
- Advice: Action taken by an aspect at a join point.
@Before,@After,@AfterReturning,@AfterThrowing,@Aroundannotations.
- Join Point: A point during execution, such as method invocation.
- Pointcut: Expressions to match join points (e.g., method patterns).
- Implementation:
- Defining aspects using
@Aspectand weaving them into the application. - XML or Java-based configuration for enabling AOP (
<aop:aspectj-autoproxy>or@EnableAspectJAutoProxy).
- Defining aspects using
- Key Features:
- Repository abstraction for database operations.
- Query creation from method names (e.g.,
findByName). - Support for custom queries with
@Query.
- Transaction Management: Automatic handling with
@Transactional.
- Purpose: Automatically exposes RESTful APIs for JPA repositories.
- Features:
- HAL explorer for navigating REST APIs.
- Custom endpoints and projections.
- Authentication: Supports username/password and role-based access.
- Authorization: Secures endpoints with roles (
@PreAuthorize,@Secured). - Thymeleaf Integration:
spring-securityextras for secure templates.
- Development:
- Creating endpoints with
@RestController. - JSON serialization and validation with
@RequestBody,@Valid.
- Creating endpoints with
- Validation: Using
@Validand@NotNullannotations. - Response Handling: Returning appropriate HTTP status codes (
ResponseEntity).
- Dynamic Views:
- HTML templates with Spring expressions (
th:text,th:if). - Form validation and error handling.
- HTML templates with Spring expressions (
- PostgreSQL:
- Configured using Spring Boot starter dependencies.
- Managed database migrations.
Contains examples and implementations of:
- Bean definitions and lifecycle.
- Bean scopes and initialization.
- Configuration methods.
Examples of:
@Autowiredwith different injection types (field, setter, and constructor).- Resolving conflicts with
@Qualifierand@Primary. - Circular dependency handling with
@Lazy.
Examples of:
- Defining aspects for logging and security.
- Implementing different types of advice (
@Before,@Around, etc.). - Configuring AOP using both annotations and XML.
This is a fully implemented school management application showcasing advanced Spring concepts. The application leverages various Spring features to provide a robust backend solution.
- AOP (Aspect-Oriented Programming):
- Logging, performance monitoring, and method-level interception.
- Spring Security:
- Secure endpoints with user authentication and authorization.
- Spring Data REST with HAL:
- Exposes RESTful APIs with hypermedia (HAL) support for easy navigation.
- Spring Data JPA:
- Simplified database interactions using JPA repositories.
- Validation:
- Input validation with
spring-boot-starter-validation.
- Input validation with
- REST APIs:
- Designed and implemented RESTful endpoints for CRUD operations.
- Thymeleaf Integration:
- For creating dynamic views and templates.
- PostgreSQL:
- Used as the database backend.
- CRUD operations for managing students, teachers, and courses.
- Role-based access control with secure endpoints.
- Auto-generated REST APIs with HAL explorer support.
- Dynamic front-end templates with form validation.
- Java Version: 21
- Maven Plugins:
- Configured with
maven-compiler-pluginfor Java 21 compatibility.
- Configured with
Stay tuned for more updates as I continue to revise and expand my Spring knowledge!