Let's start with creating a simple REST Controller method returning a string:
@RestController public class BasicController { @GetMapping("/welcome") public String welcome() { return "Hello World"; } }
A few important things to note are as follows:
- @RestController: The @RestController annotation provides a combination of @ResponseBody and @Controller annotations. This is typically used to create REST Controllers.
- @GetMapping("welcome"): @GetMapping is a shortcut for @RequestMapping(method = RequestMethod.GET). This annotation is a readable alternative. The method with this annotation would handle a Get request to the welcome URI.
If we run Application.java as a Java application, it would start up the embedded ...