Closed
Description
If more than one of the @(Method)Mapping
annotations are used, only one seems to be recognized.
Reproduction:
Put @GetMapping
and @PostMapping
together on a method of a controller:
@RestController
class AnyController {
@GetMapping("x")
@PostMapping("x")
fun x() = println("x")
}
If you now test the endpoint you see that GET /x
is mapped, but POST /x
is not (405 - Method Not Allowed).
Expectation:
The expectation is that both annotations are processed and both endpoints would be available.
At least there should be a warning that one is ignored.
Tested with:
Spring Boot 3.0.13 on Java 17.0.7
Workaround:
Use @RequestMapping(method = { ... })
.