Difference between the annotations @GetMapping and @RequestMapping(method = RequestMethod.GET)

nowszy94 :

What's the difference between @GetMapping and @RequestMapping(method = RequestMethod.GET)?
I've seen in some Spring Reactive examples, that @GetMapping was used instead of @RequestMapping

dhS :

@GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET).

@GetMapping is the newer annotaion. It supports consumes

Consume options are :

consumes = "text/plain"
consumes = {"text/plain", "application/*"}

For Further details see: GetMapping Annotation

or read: request mapping variants

RequestMapping supports consumes as well

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=418896&siteId=1