Encountered invalid @Scheduled method ‘busiHandle‘: Only no-arg methods may be annotated with @Sched

最近测试一个Scheduled 方法 报了以下的错误:

Encountered invalid @Scheduled method 'busiHandle': 
Only no-arg methods may be annotated with @Scheduled
@Scheduled(cron="*/5 * * * * *")
public void busiHandle(String s)  {
    System.out.println("执行一次");
}

是因为@Scheduled 标注的方法 不能带有参数

改成: 把 String s 参数去掉就可以了

@Scheduled(cron="*/5 * * * * *")
public void busiHandle()  {
    System.out.println("执行一次");
}

你可能感兴趣的:(spring-boot)