Let's take an example of a simple Spring Boot program:
Application.java
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class);
}
}
SuperClass.java
public abstract class SuperClass {
@Scheduled(fixedRate = 5000)
public void printSomething() {
System.out.println("this is the super method");
}
}
SubClass.java
@Component
public class SubClass extends SuperClass {
}
According to this answer, only annotations annotated by @Inherited
are inherited by subclasses, and @Scheduled does not have such an annotation. So how come this is working?