-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeek-01.java
28 lines (26 loc) · 1.12 KB
/
Week-01.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Week-01
---------------------------------------------------------------------------------------------
#Without Spring, you’d write code like this:
DoctorService doctorService = new DoctorService();
PatientService patientService = new PatientService(doctorService);
---------------------------------------------------------------------------------------------
#With Spring, you simply define these components, and Spring automatically connects them:
@Component
class DoctorService { ... }
@Component
class PatientService {
@Autowired
DoctorService doctorService;
}
---------------------------------------------------------------------------------------------
#Here’s how simple the API for booking an appointment could look with Spring Boot:
@RestController
@RequestMapping("/appointments")
public class AppointmentController {
@PostMapping("/book")
public String bookAppointment(@RequestBody Appointment appointment) {
// Logic to save appointment in the database
return "Appointment booked successfully!";
}
}
---------------------------------------------------------------------------------------------