What is the primary role of the @RestController annotation in Spring Boot?
- To create a request mapping for HTTP GET requests.
- To define a controller class in Spring Boot.
- To indicate a Spring Boot application's version.
- To specify the package structure of the Spring Boot project.
The primary role of the @RestController annotation in Spring Boot is to define a controller class. It marks a Java class as a controller and combines @Controller and @ResponseBody annotations. This annotation is used to create RESTful web services, and it simplifies the process of building REST APIs by eliminating the need to annotate individual methods with @ResponseBody. It doesn't specify the package structure or application version.
Loading...
Related Quiz
- Which annotation is used to disable full auto-configuration and instead apply only configuration relevant to JPA tests in Spring Boot?
- In Spring Boot, when testing service layer components, the _____ annotation can be used to avoid loading the complete ApplicationContext.
- How can @ControllerAdvice be used to customize the response body of a global exception handler?
- You need to optimize a Spring Boot application for faster startup times. What strategies and configurations would you employ for this optimization?
- What is the purpose of the @RestController annotation in a Spring Boot application?