Closed
Description
Kazuki Shimizu opened SPR-12509 and commented
When use the @ControllerAdvice(basePackageClasses)
, it has been applied to the other base package's Controller
.
e.g)
package io.github.kazuki43zoo.app;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
@ControllerAdvice(basePackageClasses = io.github.kazuki43zoo.app.AppControllerAdvice.class)
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 Controller
under io.github.kazuki43zoo.app
and io.github.kazuki43zoo.app1
package.
I think that should not be applied to the Controller
under io.github.kazuki43zoo.app1
package.
p.s)
basePackages
and value
attribute is similar behavior.
Affects: 4.1.2
Reference URL: https://github.com/kazuki43zoo/spring-controller-advice
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 - When specified the Non-existent package using @ControllerAdvice(basePackages), has been applied to all controllers. [SPR-12510] #17115 When specified the Non-existent package using
@ControllerAdvice
(basePackages), has been applied to all controllers.
Referenced from: commits d1f8968