From the course: Spring on Kubernetes: Deploying and Managing Cloud-Native Applications

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Cloud Native Spring

Solution: Cloud Native Spring

(bright electronic music) - [Instructor] And now it's time for my solution to this exercise. I'm going to start by showing you how I handled the exceptions. So, in Source, Main, Java in the util, I created two exceptions. One is for the bad request. You'll notice here on line 6 that I put in a response status of bad request. I also extended runtime exception. I did the same on the NotFound, of course changing the response status on line 6 to NotFound. So, now in the data I created an entity for product, for service, and for vendor, and I created a product repository with a findByName, a service repository with a findByName, and a vendor repository with a findByEmail, all of those matching the unique values. Then I created, in the Customer Controller, I went ahead and finished out this by doing a post-mapping for the created flow, starting on line 54. Line 60, I did the getById. Notice if the optional customer is not present, I return a NotFound. I then did a PutMapping on line 69. To…

Contents