Complete the code to mark the class as a service in Spring Boot.
[1] public class UserService { // service methods }
The @Service annotation marks the class as a service component in Spring Boot.
Complete the code to inject the service into a controller using Spring Boot.
public class UserController { private final UserService userService; public UserController([1] userService) { this.userService = userService; } }
The constructor parameter must be the type UserService to inject the service.
Fix the error in the service class declaration by adding the missing annotation.
[1] public class OrderService { public void processOrder() { // processing logic } }
The @Service annotation is required to register the class as a service bean.
Fill both blanks to create a service class and inject it into a controller.
@Service public class ProductService { public String getProduct() { return "Product"; } } public class ProductController { private final [1] productService; public ProductController([2] productService) { this.productService = productService; } }
Both blanks require the service class name ProductService to correctly declare and inject the service.
Fill all three blanks to define a service, annotate it, and inject it into a controller.
[1] public class CustomerService { public String getCustomer() { return "Customer"; } } public class CustomerController { private final [2] customerService; public CustomerController([3] customerService) { this.customerService = customerService; } }
The service class must be annotated with @Service. The field and constructor parameter types must be CustomerService.