Prevent duplicate controller registrations through class-level @RequestMapping.

When we detected @BasePathAwareController and @RepositoryRestController instances, we now reject types that use @RequestMapping on the class level as doing so causes an inevitable registration of the controller with Spring MVC.

Fixes #1342, #1628, #1686, #1946.
This commit is contained in:
Oliver Drotbohm
2021-10-05 19:21:25 +02:00
parent 2e1223c46c
commit a6de3b18c4
4 changed files with 59 additions and 12 deletions

View File

@@ -59,10 +59,9 @@ public class JpaRepositoryConfig extends JpaInfrastructureConfig {
}
@RepositoryRestController
@RequestMapping("orders")
static class OrdersJsonController {
@RequestMapping(value = "/search/sort", method = RequestMethod.POST, produces = "application/hal+json")
@RequestMapping(value = "/orders/search/sort", method = RequestMethod.POST, produces = "application/hal+json")
void someMethodWithArgs(Sort sort, Pageable pageable, DefaultedPageable defaultedPageable) {}
}
}