Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取@Scheduled内的fixedDelay值_Java_Spring_Scheduled Tasks - Fatal编程技术网

Java 获取@Scheduled内的fixedDelay值

Java 获取@Scheduled内的fixedDelay值,java,spring,scheduled-tasks,Java,Spring,Scheduled Tasks,是否可以在正在执行的方法内部获取fixedDelay的值 是否存在类似的情况: @Scheduled(fixedDelay = 86400000) //one day public void sendEmails() { System.out.println(TaskExecutor.getCurrentFixedDelay()); // (would print 86400000) } public class AnnotationParameter { @

是否可以在正在执行的方法内部获取
fixedDelay
的值

是否存在类似的情况:

@Scheduled(fixedDelay = 86400000) //one day
public void sendEmails() {
    System.out.println(TaskExecutor.getCurrentFixedDelay()); // (would print 86400000)
}
    public class AnnotationParameter {

        @Scheduled(fixedDelay = 86400000) //one day
        public void sendEmails() throws NoSuchMethodException
        {
            Method method = AnnotationParameter.class.getDeclaredMethod
                ("sendEmails");
            Scheduled annotation = method.getAnnotation(Scheduled.class);
            long fixedDelay = annotation.fixedDelay();
            System.out.println(fixedDelay); // (would print 86400000)
        }

        public static void main(String[] args) throws NoSuchMethodException
        {
            new AnnotationParameter().sendEmails();
        }
    }