Only no-arg methods may be annotated with @Scheduled

今天药忘吃喽~ 2022-05-14 12:57 331阅读 0赞

SpringBoot启动的项目,定时任务@Scheduled报错

这里我的方法是:

  1. @Scheduled(cron = "0 0/1 * * * ? ")
  2. public ResponseEntity pushRiskResult(String nid, Integer noticeNum) {
  3. log.warn("定时任务");
  4. }

项目启动时报错:

  1. Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'pushResult': Only no-arg methods may be annotated with @Scheduled
  2. at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.processScheduled(ScheduledAnnotationBeanPostProcessor.java:462)
  3. at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:332)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
  7. ... 28 common frames omitted

错误提示是:@Scheduled注解的方法不能有入参

  1. Only no-arg methods may be annotated with @Scheduled

发表评论

表情:
评论列表 (有 0 条评论,331人围观)

还没有评论,来说两句吧...

相关阅读