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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *