答案是 不
除非注释类型具有@Inherited元注释,否则Java注释不会继承:https : //docs.oracle.com/javase/7/docs/api/java/lang/annotation/Inherited.html。
Spring的@Component注释上没有
@Inherited,因此你需要将注释放在每个组件类上。@ Service,@ Controller和@Repository都没有。

答案是 不
除非注释类型具有@Inherited元注释,否则Java注释不会继承:https : //docs.oracle.com/javase/7/docs/api/java/lang/annotation/Inherited.html。
Spring的@Component注释上没有
@Inherited,因此你需要将注释放在每个组件类上。@ Service,@ Controller和@Repository都没有。