From the course: Spring Boot 3 Essential Training
Unlock this course with a free trial
Join today to access over 24,300 courses taught by industry experts.
Extracting a service layer - Spring Boot Tutorial
From the course: Spring Boot 3 Essential Training
Extracting a service layer
- [Instructor] In the interest of not repeating ourselves, we're going to do a little bit of refactoring of our code in a common way and that is to build a service or business service layer between our data access and our view. So what I want you to do is to open up room web app, source, main, Java, and we'll create a package underneath our default package. And we will call this service. Now in here we will create a new Java class and we will call this room service. Now we're going to annotate this with @Service, which is a stereotype of @Component. That way we can auto wire it. And in order for this to work, we are going to need a private final room repository and we will inject that via the constructor. Now we're going to create a few methods. So let's start with the first one, which is going to be public list of our rooms. And this is from the web package, get all rooms, and we're not going to get to implementing these yet. Let's go ahead and define the interface. So we will do a…
Contents
-
-
-
-
-
-
Configuring embedded Tomcat5m 26s
-
(Locked)
Employing MVC in Spring Boot2m 25s
-
(Locked)
Thymeleaf templates4m 37s
-
(Locked)
Web application with Spring Boot5m 40s
-
(Locked)
Challenge: Generate an MVC webpage55s
-
(Locked)
Solution: Generate an MVC webpage2m 24s
-
(Locked)
Web services with Spring Boot1m 4s
-
(Locked)
Extracting a service layer6m 42s
-
(Locked)
Building the web service4m 40s
-
(Locked)
Challenge: Build a web service43s
-
(Locked)
Solution: Build a web service1m 51s
-
(Locked)
Calling a web service4m 35s
-
-
-