Spring Core @Value Annotation - Scenario Based Tasks
Task 1 – Online Grocery Store Discount System
Project Name: GroceryDiscountApp
Objective: Create a Spring Core Maven application that uses @Value annotation to inject grocery store details and
discount information.
Requirements:
1. Create Maven Project and add Spring Core dependency in [Link].
2. Create Class: [Link]
3. Annotate class with @Component.
4. Use @Value annotation to inject all field values.
Fields:
• storeId
• storeName
• location
• discountPercentage
• homeDeliveryAvailable
Methods:
• showStoreDetails()
• calculateDiscount(double amount)
5. Create Configuration Class with @Configuration and @ComponentScan.
6. Create Main Class.
Main Class Requirements: Load Spring container, get bean from container, display store details and calculate
grocery discount.
Task 2 – Movie Ticket Booking System
Project Name: MovieTicketBookingApp
Objective: Develop a movie booking application using Spring Core where ticket pricing and theater details are
injected using @Value.
Requirements:
1. Create Maven Project and add Spring Core dependency in [Link].
2. Create Class: [Link]
3. Annotate class with @Component.
4. Use @Value annotation to inject all field values.
Fields:
• theaterName
• movieName
• ticketPrice
• availableSeats
• imaxAvailable
Methods:
• bookTickets(int seats)
• showMovieDetails()
5. Create Configuration Class with @Configuration and @ComponentScan.
6. Create Main Class.
Main Class Requirements: Book tickets, reduce available seats and display final booking information.
Task 3 – Hospital Patient Registration System
Project Name: HospitalRegistrationApp
Objective: Create a patient registration system where hospital and doctor information are injected using @Value.
Requirements:
1. Create Maven Project and add Spring Core dependency in [Link].
2. Create Class: [Link]
3. Annotate class with @Component.
4. Use @Value annotation to inject all field values.
Fields:
• hospitalId
• hospitalName
• doctorName
• consultationFee
• emergencyAvailable
Methods:
• registerPatient(String patientName)
• showHospitalInfo()
• calculateTotalBill(int days)
5. Create Configuration Class with @Configuration and @ComponentScan.
6. Create Main Class.
Main Class Requirements: Register multiple patients, display hospital information and calculate patient bill.
Task 4 – Mobile Recharge Service System
Project Name: MobileRechargeApp
Objective: Build a recharge service application using Spring Core where recharge plan details are injected using
@Value.
Requirements:
1. Create Maven Project and add Spring Core dependency in [Link].
2. Create Class: [Link]
3. Annotate class with @Component.
4. Use @Value annotation to inject all field values.
Fields:
• providerName
• planName
• validityDays
• planPrice
• dataLimitPerDay
Methods:
• showPlanDetails()
• calculateYearlyExpense()
5. Create Configuration Class with @Configuration and @ComponentScan.
6. Create Main Class.
Main Class Requirements: Display recharge plan details, calculate yearly recharge expense and show provider
information.