记录一下今天写代码时出现的bug <font size="3"> Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method ‘getPlanBoardStatistics’: Only no-arg methods may be annotated with @Scheduled at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.processScheduled(ScheduledAnnotationBeanPostProcessor.java:496) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.lambda$null$1(ScheduledAnnotationBeanPostProcessor.java:359) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_181] </font>
使用spring的@Scheduled()注解时候,报了这个错误,报错原因是@Scheduled()注解不能使用在带参数的方法中。 注意:使用@Scheduled()注解的时候,要记得在启动类上使用@EnableScheduling注解开启定时器。