From the course: Spring Boot 2.0 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Build a web service

Solution: Build a web service

From the course: Spring Boot 2.0 Essential Training

Start my 1-month free trial

Solution: Build a web service

(upbeat music) - [Instructor] And here is my solution to this challenge exercise. So what I did in source main Java in my controller package underneath the root I created a new element called StaffRestController and it works very much the same way that my RoomRestController worked. So I responded /api/staff and that's probably not the best from a true rest perspective but for the purposes here, it'll work fine. I get a staff service element that I inject as part of my constructor and spring does that automatically without an auto wiring because that's my only constructor on this class. And this is a component by nature of being a controller. I didn't execute a get mapping on a method that returns a list of staff member elements from that service. So let's go ahead and run this application, and I'll jump back into terminal. I'm going to do an HTTP once again against 8080/api/staff. And there is my elements. And…

Contents