Closed
Description
Kazuki Shimizu opened SPR-12510 and commented
e.g)
package io.github.kazuki43zoo.app;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
@ControllerAdvice(basePackages = "xxxx")
public class AppControllerAdvice {
@ModelAttribute("appCommonMessage")
public String commonMessage() {
System.out.println("AppControllerAdvice#appCommonMessage() called.");
return "Hello in AppControllerAdvice.";
}
}
Above @ModelAttribute
method has been applied to the all controllers.( e.g: controllers under io.github.kazuki43zoo.app
package).
I think feel unnatural in this behavior.
This behavior is specification ?
As related information ..
When specified the Non-existent package using @ComponentScan(basePackages)
, controller is not scanned.
I think should be changed to the same behavior with @CompnentScan
.
How do think ?
Affects: 4.0.8, 4.1.2
Issue Links:
- Base packages referenced from @ControllerAdvice must contain at least one Controller [SPR-12506] #17111 Base packages referenced from
@ControllerAdvice
must contain at least one Controller ("duplicates") - @ControllerAdvice(basePackageClasses) do the prefix search by package name. [SPR-12509] #17114
@ControllerAdvice
(basePackageClasses) do the prefix search by package name.
Backported to: 4.0.9