https://github.com/IsraaXx/SpringBoot-Library-Service_BanqueMisr
- 1: Ziyad Sherif (Team Leader)
- 2: إسراء محمد السيد محمد
- 3:ندى محيى الدين حافظ عبدالعال
This Spring Boot project demonstrates core concepts of Spring such as Dependency Injection, Profiles, Configuration Properties, Component Scanning, and full CRUD operations. The application simulates a simple library system.
- Initialized a Spring Boot project using Spring Initializr with Web and Spring Data JPA dependencies.
- Created the
@SpringBootApplicationmain class inside a base package:com.sprints.library. - Exposed a
/healthendpoint that returns"OK"to confirm service is up.
- Created a
GreetingServiceinterface with two implementations:MorningServiceEveningService
- Injected the service into a controller in three ways:
- Constructor Injection
- Setter Injection
- Field Injection
- Created the following configuration files:
application.propertiesapplication-dev.ymlapplication-prod.yml
- Externalized the following properties:
library.namelibrary.mode
- Created a
LibraryConfigclass with@ConfigurationPropertiesto bind these values. - Demonstrated profile activation by setting
spring.profiles.active=devorprod.
- Organized packages by feature:
controllerservicerepositorymodelconfig
- Used
@ComponentScanwith include/exclude filters to selectively load beans. - Wrote a simple test to assert that excluded beans are not loaded into the application context.
- Created two implementations of
NotificationService:EmailNotificationService(annotated with@Primary)SmsNotificationService(annotated with@Qualifier("sms"))
- Injected both into
NotificationController, with endpoints:/notify/email/notify/sms
- Created a
Bookentity with fields likeid,title,author. - Created a
BookRepositoryImplemented an in-memory list to store books. - Created a
BookServicethat simply delegates calls to the repository. - Built a
BookControllerthat supports full CRUD via REST endpoints:GET /api/booksGET /api/books/{id}POST /api/booksPUT /api/books/{id}DELETE /api/books/{id}
com.sprints.library
├── config
├── controller
├── service
├── repository
├── model
└── LibraryApplication.java
application.properties(contains common configuration)application-dev.ymlandapplication-prod.yml(contains environment-specific properties)
- Clone the repository
- Set profile:
spring.profiles.active=devinapplication.properties - Run the application using your IDE or
./mvnw spring-boot:run - Access endpoints like
/health,/api/books,/notify/email
- Make sure your profile-specific YAML files are properly indented.
- Ensure dependencies are up to date in your
pom.xml - Customize
library.nameandlibrary.modeper environment For any issues or contributions, feel free to open a pull request or contact the team members.