Skip to content

Log warning if multiple @PostMapping, @GetMapping, etc. annotations are declared #31962

Closed
@calliduslynx

Description

@calliduslynx

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 = { ... }).

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation tasktype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions