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
@SpringBootApplication
main class inside a base package:com.sprints.library
. - Exposed a
/health
endpoint that returns"OK"
to confirm service is up.
- Created a
GreetingService
interface with two implementations:MorningService
EveningService
- Injected the service into a controller in three ways:
- Constructor Injection
- Setter Injection
- Field Injection
- Created the following configuration files:
application.properties
application-dev.yml
application-prod.yml
- Externalized the following properties:
library.name
library.mode
- Created a
LibraryConfig
class with@ConfigurationProperties
to bind these values. - Demonstrated profile activation by setting
spring.profiles.active=dev
orprod
.
- Organized packages by feature:
controller
service
repository
model
config
- Used
@ComponentScan
with 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
Book
entity with fields likeid
,title
,author
. - Created a
BookRepository
Implemented an in-memory list to store books. - Created a
BookService
that simply delegates calls to the repository. - Built a
BookController
that supports full CRUD via REST endpoints:GET /api/books
GET /api/books/{id}
POST /api/books
PUT /api/books/{id}
DELETE /api/books/{id}
com.sprints.library
├── config
├── controller
├── service
├── repository
├── model
└── LibraryApplication.java
application.properties
(contains common configuration)application-dev.yml
andapplication-prod.yml
(contains environment-specific properties)
- Clone the repository
- Set profile:
spring.profiles.active=dev
inapplication.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.name
andlibrary.mode
per environment For any issues or contributions, feel free to open a pull request or contact the team members.