Want a clean, beginner-safe comparison of HTTP method annotations? Here’s a concise, practical map of GET, POST, PUT, DELETE, PATCH across Spring Boot and Quarkus (Jakarta REST/JAX-RS).
🔸 GET (READ) 📥
▪️ Spring import: org.springframework.web.bind.annotation.GetMapping
▪️ Quarkus import: jakarta.ws.rs.GET (with jakarta.ws.rs.Path)
▪️ Definition: Retrieve a resource. Safe and idempotent.
▪️ Differences:
Spring combines method + path in one annotation: @GetMapping("/items") (optionally produces, consumes).
Quarkus/JAX-RS splits concerns: class/method @Path("/items") + @GET; media types via @Produces/@Consumes.
🔸 POST (CREATE / ACTION) 🧩
▪️ Spring import: org.springframework.web.bind.annotation.PostMapping
▪️ Quarkus import: jakarta.ws.rs.POST
▪️ Definition: Create a resource or execute a non-idempotent action.
▪️ Differences:
Spring: @PostMapping("/items") + @RequestBody for payload; return ResponseEntity or body directly.
Quarkus: @POST + entity parameter (no @RequestBody) and @Consumes; return entity or jakarta.ws.rs.core.Response to control status/headers.
🔸 PUT (REPLACE) ♻️
▪️ Spring import: org.springframework.web.bind.annotation.PutMapping
▪️ Quarkus import: jakarta.ws.rs.PUT
▪️ Definition: Replace a resource entirely. Idempotent by convention.
▪️ Differences:
Spring: @PutMapping("/items/{id}"), typical params: @PathVariable, @RequestBody.
Quarkus: @PUT + @Path("/{id}"), typical params: @PathParam("id"), entity parameter; use @Consumes for media type.
🔸 DELETE (REMOVE) 🗑️
▪️ Spring import: org.springframework.web.bind.annotation.DeleteMapping
▪️ Quarkus import: jakarta.ws.rs.DELETE
▪️ Definition: Delete a resource. Idempotent by convention (repeated DELETEs yield same state).
▪️ Differences:
🔸 PATCH (PARTIAL UPDATE) ✂️
▪️ Spring import: org.springframework.web.bind.annotation.PatchMapping
▪️ Quarkus import: jakarta.ws.rs.PATCH (Jakarta REST 3.1+; in older stacks people used a custom @HttpMethod("PATCH"))
▪️ Definition: Apply a partial modification to a resource. Often non-idempotent (implementation-dependent).
▪️ Differences:
Spring: @PatchMapping("/items/{id}") + @RequestBody (e.g., JSON Patch/Merge Patch if you choose).
Quarkus: @PATCH + entity parameter; you choose patch format and validation; return Response to express 204/200/409, etc.
🔸 PATHS, MEDIA TYPES & PARAMS 🧭
▪️ Spring imports (common):
org.springframework.web.bind.annotation.RequestMapping (base path)
org.springframework.web.bind.annotation.RequestParam (query)
org.springframework.web.bind.annotation.PathVariable (path)
org.springframework.web.bind.annotation.RequestBody (body)
▪️ Quarkus/JAX-RS imports (common):
jakarta.ws.rs.Path (class/method path)
jakarta.ws.rs.Produces, jakarta.ws.rs.Consumes (media)
jakarta.ws.rs.QueryParam (query)
jakarta.ws.rs.PathParam (path)
jakarta.ws.rs.core.Response (status/headers control)
▪️ Key differences:
Spring bundles a lot into @*Mapping, while Quarkus keeps HTTP method, path, and media type concerns separate (clear, explicit JAX-RS style).
🔸 TL;DR 🧾
▪️ Spring Boot:
@Get/Post/Put/Delete/PatchMapping = method + path (and often media types) in one place.
▪️ Quarkus:
@GET/@POST/@PUT/@DELETE/@PATCH + @Path + @Produces/@Consumes = explicit, modular setup following JAX-RS.
▪️ Params differ:
@RequestParam/@PathVariable/@RequestBody (Spring) vs @QueryParam/@PathParam + entity parameter (Quarkus).
▪️ Return types:
both can return bodies directly; use Response (JAX-RS) or ResponseEntity (Spring) for fine-grained control.
🔸 TAKEAWAYS ✅
▪️ Choose Spring’s @*Mapping for concise, familiar annotations in Spring apps.
▪️ Choose JAX-RS style in Quarkus for explicit separation of concerns and portable Jakarta REST patterns.
▪️ PATCH exists natively in modern Jakarta REST (jakarta.ws.rs.PATCH); legacy stacks may need a custom workaround.
▪️ Prefer typed responses plus Response/ResponseEntity when you need control over status codes/headers.
▪️ Keep idempotency semantics in mind: GET/PUT/DELETE are typically idempotent; POST often isn’t; PATCH depends on your design.
#Java #Quarkus #SpringBoot #JakartaEE #JAXRS #REST #API #Microservices #Backend #HTTP
Go further with Java certification:
Java👇
Spring👇