强制派生类声明自己为Springbean
我如何控制,所有派生自某个类的类都必须声明为强制派生类声明自己为Springbean,spring,spring-annotations,Spring,Spring Annotations,我如何控制,所有派生自某个类的类都必须声明为@Component(即Springbean)?Spring是否提供了一种通过父类进行控制的机制?Workarround:如果父类的子类没有@组件注释,则可以使用[AspectJ声明警告][1](或错误) (我不是AspectJ专家,因此我无法为您编写所需的AJP声明。但几年前我也做过类似的事情,因此我非常确信这种方法是有效的。) 粗略草图,可能包含一些语法错误: pointcut requiresComponentAnnotation(): your
@Component
(即Springbean)?Spring是否提供了一种通过父类进行控制的机制?Workarround:如果父类的子类没有@组件注释,则可以使用[AspectJ声明警告][1](或错误)
(我不是AspectJ专家,因此我无法为您编写所需的AJP声明。但几年前我也做过类似的事情,因此我非常确信这种方法是有效的。)
粗略草图,可能包含一些语法错误:
pointcut requiresComponentAnnotation(): yourParentClass+
&& !get(@Component)
declare warning : requiresComponentAnnotation() :
"expect: @Type(type = \"org.springframework.stereotyp.Component\")";
这可能是一个解决方案的好主意-谢谢-尽管我正在寻找一个随时可用的机制。