Base packages referenced from @ControllerAdvice must contain at least one Controller [SPR-12506] #17111
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Nestor Tarin Burriel opened SPR-12506 and commented
When having a controller package structure like:
and no controller exists in package my.controller but in sub-packages server, user and group the
@ControllerAdvice
is applied to all controllers instead of only the ones in package my.controller.So, for example, following the above package structure if I would like to have two different
@ControllerAdvice
, one for all controller contained in the package my.controller and another one for the ones contained in my.other.controller I need to add a dummy controller on each package in order to apply the correct advice.The controller advice documentation points out that you should consider to have such a dummy controller in order to reference it from the advice
As other usages of the same kind of annotation property (e.g.
@ComponentScan
.basePackages) I expected not to have such a dummy controller but let the framework find them in the sub packagesAffects: 4.0.6
Issue Links:
@ControllerAdvice
(basePackages), has been applied to all controllers. ("is duplicated by")@ControllerAdvice
(basePackageClasses) do the prefix search by package name.Referenced from: commits 4013fe0, 1d6978a
Backported to: 4.0.9
The text was updated successfully, but these errors were encountered: