同样的代码,在springboot项目中,每1s执行一次,但是在maven项目中,需要每3s才执行一次,为什么呢?
@Component
@EnableScheduling
@EnableAsync
public class TestScheduler {
private static final Logger logger = LoggerFactory.getLogger(TestScheduler.class);
@Async
@Scheduled(initialDelay = 1 * 1000L, fixedDelay = 1 * 1000L)
public void fixedDelay() {
try {
logger.info("--fixedDelay--");
Thread.sleep(1000 * 2000);
} catch (InterruptedException e) {
}
}
}