From the course: Learning Spring 6 with Spring Boot 3

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Expose a service layer through REST

Expose a service layer through REST - Spring Tutorial

From the course: Learning Spring 6 with Spring Boot 3

Expose a service layer through REST

- [Instructor] So as promised, now it's time to jump in and create a restful base web service. All right, the first thing that I want you to do is to open up source main Java, and underneath the base package we'll create a new package called web exception. And in there we're going to create a couple quick classes. The first one will be a bad request exception. We're going to do a response status on this of bad request. This will extend runtime exception, and I will simply override the four primary methods. And now we're going to do the same for a not found exception, a response status of not found, extend our runtime exception and override the first four methods. Now this gives us an easy way to throw an exception in the use cases that will translate to an HTTP exception. Now let's create a new package underneath web called API. And in there we will create a Java class. And this will be called the Room API Controller. All…

Contents