@Scheduled(cron = "0 0 0 ? * 5#3")不支持。


已提交的issue : https://github.com/spring-projects/spring-framework/issues/22436

@Scheduled(cron = "0 0 0 ? * 5#3") 不支持。

代码如下 :

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@SpringBootApplication
@EnableScheduling
public class TestScheduledApplication{
    public static void main(String[] args) {
        SpringApplication.run(TestScheduledApplication.class, args);
    }
    @Scheduled(cron = "0 0 0 ? * 5#3")
    public void testScheduled(){
        System.out.println("hello world");
    }
}

报错如下 :

Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'testScheduled': For input string: "5#3"
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.processScheduled(ScheduledAnnotationBeanPostProcessor.java:469) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$null$1(ScheduledAnnotationBeanPostProcessor.java:333) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_77]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$postProcessAfterInitialization$2(ScheduledAnnotationBeanPostProcessor.java:333) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:676) ~[na:1.8.0_77]
	at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:332) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
	... 15 common frames omitted`


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM