找出运行时调度器始终无法识别这个任务的原因。
Java
import java.lang.annotation.*;
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
@interface Scheduled {}
class CleanupJob {
@Scheduled
public void run() {}
}
public class Main {
public static void main(String[] args) throws Exception {
var method = CleanupJob.class.getDeclaredMethod("run");
System.out.println(method.isAnnotationPresent(Scheduled.class));
}
}