Difference between the annotations GetMapping and RequestMappingmethod RequestMethod.GET
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Spring MVC and Spring Boot controllers, @GetMapping and @RequestMapping(method = RequestMethod.GET) both map HTTP GET requests to a handler method. The practical difference is not behavior in normal use, but intent: @GetMapping is the concise, GET-specific form, while @RequestMapping is the more general mapping annotation that can describe many kinds of request rules.
They Mean The Same HTTP Method
At the method level, these two handlers are equivalent in purpose.
Both map GET requests for /users to the same controller method. If all you need is a normal GET endpoint, @GetMapping is usually clearer because the HTTP method is visible immediately.
Why @GetMapping Exists
@GetMapping is a composed shortcut annotation. It exists to reduce boilerplate and make controller methods easier to scan.
When a controller has many endpoints, a row of @GetMapping, @PostMapping, @PutMapping, and @DeleteMapping annotations is easier to understand than repeating @RequestMapping(method = ...) everywhere.
That readability benefit is the main reason most modern Spring code prefers @GetMapping for simple GET handlers.
What @RequestMapping Still Does Better
@RequestMapping is still important because it is the base annotation for request mapping rules in Spring. It is often used at the class level to define a shared path prefix.
This is a common pattern: use @RequestMapping once on the class, then use the HTTP-specific annotations on individual methods.
Shared Attributes
The two forms can express the same mapping constraints for a GET route, including path, query parameter requirements, headers, consumes, and produces.
So the decision is usually about clarity, not capability.
When To Prefer Each One
Use @GetMapping when the method handles only GET requests. That is the ordinary choice for REST read endpoints and page-loading handlers.
Use @RequestMapping when you need the generic form, especially at the class level or in legacy code where a controller uses one style consistently. It is also the annotation you reach for when teaching how Spring request mapping works at a lower level.
Common Pitfalls
A common mistake is assuming @GetMapping is more powerful or more modern in behavior than @RequestMapping(method = RequestMethod.GET). For a GET handler, it is mostly a cleaner wrapper around the same idea.
Another mistake is mixing mapping styles inconsistently in the same controller without a reason. That makes the codebase harder to scan. Pick a pattern and keep it consistent.
It is also easy to forget that @RequestMapping without method = RequestMethod.GET is not GET-specific at all. If you omit the method attribute, the handler may match more broadly than intended.
Summary
- '
@GetMappingand@RequestMapping(method = RequestMethod.GET)both map GET requests.' - '
@GetMappingis the shorter, clearer form for GET-only handler methods.' - '
@RequestMappingis the general-purpose annotation and is still common at the class level.' - Both forms support path, headers, params, and media-type conditions.
- Prefer
@GetMappingfor simple GET endpoints unless a broader@RequestMappingstyle is needed.

