@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