A comprehensive Spring Boot application for an e-commerce platform, demonstrating the use of Spring MVC, Spring Data JPA, and Spring Security. The project is structured to showcase best practices in dependency injection, service-oriented architecture, and data management.
- Uses Spring's IoC container to manage beans and dependencies.
- Demonstrates field, constructor, and setter injection.
- Includes examples of
@Autowired,@Qualifier, and@Primaryannotations.
-
Controller Layer:
- Handles HTTP requests and responses using
@RestController,@RequestMapping, and related annotations. - Example:
HomeControllerfor greeting messages and managing endpoints.
- Handles HTTP requests and responses using
-
Service Layer:
- Contains business logic classes.
- Example:
ProductServicemanages product-related operations like fetching and filtering.
-
Repository Layer:
- Implements data persistence using Spring Data JPA.
- Uses Hibernate for ORM and demonstrates the use of
@Queryfor custom JPQL queries.
- Handles both layout and data transfers.
- Front Controller maps incoming HTTP requests to the appropriate handler methods.
- Configured with H2 Database for lightweight, in-memory persistence during development.
- Demonstrates Spring Boot's
application.propertiesfor database and server configuration.
- Utilizes Spring Security for authentication and access control.
- Includes examples of session management and filters for secure data handling.
- Implements
@GetMapping,@PostMapping, and other HTTP method annotations. - Example:
/productsendpoint to retrieve all products or search by ID.
- Cross-Origin Resource Sharing (CORS): Uses
@CrossOriginto allow requests from different domains. - Error Handling: Demonstrates the use of
ResponseEntityfor sending HTTP status codes alongside responses.
- Lombok: Reduces boilerplate code for getters, setters, and constructors.
- Jackson: Facilitates JSON serialization and deserialization.
- Clone the repository:
- Navigate to the project directory:
- Build the application:
- Run the application:
- Access the application at http://localhost:8080.
Modify application.properties for custom configurations:
server.port=8081
spring.datasource.url=jdbc:h2:mem:testDB
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.show-sql=true