Spring @RestController Annotation Example
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ6xZexu6wifEJv6St6fjzeFUmDQs-Z1ITQ0eI70wVPSM_YXaxGniZj8B7CywsfpVdWvb1LlXlsD_zQ4qx0Fnlokxknu4f2f1uls03Fc8VrODEmmCOR-FpbNn8JQnExBzLMcEsKX3W78cSkjAmOAP9AY6rymI9ZARWgE9lPdZS0o4hB1YFv8PeKUiRuQ/w400-h156/Untitled%20Diagram.drawio%20(5).png)
In this section we will learn about @RestController Annotation. The @RestController annotation is mainly utilized for building restful web services utilizing Spring MVC. It is a convenience annotation, this annotation itself annotated with @ResponseBody and @Controller annotation. The class annotated with @RestController annotation returns JSON replication in all the methods. @RestController public class UserController { @GetMapping ( "/users" ) public User getUser ( ) { //TODO } } The following example creates a Spring Boot web application which uses @RestController . Project Directory Pom.xml <? xml version ="1.0" encoding ="UTF-8" ?> < project xmlns ="http://maven.apache.org/POM/4.0.0" xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi :schemaLocation ="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" > < modelVersion &g